Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Caktus sponsoring and speaking on mobile health at SwitchPoint 2013
SwitchPoint is a one-of-a-kind conference and a unique opportunity to learn, share ideas, and hear about global and mobile health efforts around the world. We had a great time at SwitchPoint last year. I’m excited to announce that Caktus, for the second year in a row, is sponsoring SwitchPoint 2013. At Caktus, we enjoy working on projects that have a positive social impact and have had the opportunity to implement mobile health projects around the world, including in Nigeria, Rwanda, Zambia and Malawi. Caktus currently leads the development of RapidSMS, a free and open-source framework (built in Django) for dynamic data collection, logistics coordination and communication through text messaging (SMS). RapidSMS is used widely across Africa and other parts of the world to improve patient outcomes and save lives in urban and rural areas. Over the past 11 months, Caktus has organized efforts around improving the RapidSMS core codebase, including infrastructure enhancements and coordinating community involvement and participation. Additionally, Caktus is collaborating on UNICEF’s 1000 Days Product, which tracks the first 1000 days between a woman’s pregnancy and her child’s second birthday. 1000 days not only tracks nutrition, which is very important during early child development, but also includes mobile … -
Scheduling Periodic Tasks with Celery 2.3.3 and Django 1.4
There are going to be times in the life of your application when you'll need to perform tasks - making requests to APIs, sending emails, or storing large amounts of data, for example. To do that, you'll most likely want to implement some sort of job queue - that is, a system that lines these tasks up and executes them. Celery is a task queue commonly used with Django - it's open source, easy to integrate with many other languages and frameworks, and it can execute tasks either asynchronously (in the background) or synchronously (wait until ready). This article is going to talk about a very basic Celery implementation for Django - you'll need to have Django installed already, and we'll discuss installing and configuring celery, django-celery (Celery integration for Django), and RabbitMQ (the recommended message broker for celery). If you're using an older version of Celery, it may be a little challenging finding the right docs - for 2.3.3, start with this link: http://docs.celeryproject.org/en/v2.3.3/ And you may want to bookmark this for future reference - the Celery account on GitHub contains repositories for the official celeryproject, as well as django-celery and kombu. https://github.com/celery Installing and configuring Before you get … -
Two Scoops of Django is in print!
Since I was a child I wanted to be a published author. I've dreamt of people reading my book. While one could say that dream was fulfilled when we launched the e-book version in January, it's not the same as seeing the printed copy. Today I got to see my dream come true, a printed book is out there with my name on it. Also, I have a confession to make. When it comes to technical books, I really prefer the print version. For me, nothing beats being able to flip through pages of a hardcopy next to a keyboard, or simply reading while I'm on a bus, train, or plane. So this adds to my excitement when I get to say that the book that Audrey Roy and I wrote together is in print. Note: As of April 17th it's only available in the US. However, it's in the queue for being available for Amazon Europe. Enough people are asking that we are also looking into getting it bulk shipped to Django Circus. While it's been an amazing journey, it's also been a long hard road. Starting with a late night dinner with Randall Degges, his wife Samantha, and … -
Two Scoops of Django is in print!
Since I was a child I wanted to be a published author. I've dreamt of people reading my book. While one could say that dream was fulfilled when we launched the e-book version in January, it's not the same as seeing the printed copy. Today I got to see my dream come true, a printed book is out there with my name on it. Also, I have a confession to make. When it comes to technical books, I really prefer the print version. For me, nothing beats being able to flip through pages of a hardcopy next to a keyboard, or simply reading while I'm on a bus, train, or plane. So this adds to my excitement when I get to say that the book that Audrey Roy and I wrote together is in print. Note: As of April 17th it's only available in the US. However, it's in the queue for being available for Amazon Europe. Enough people are asking that we are also looking into getting it bulk shipped to Django Circus. While it's been an amazing journey, it's also been a long hard road. Starting with a late night dinner with Randall Degges, his wife Samantha, and … -
Logging time, part 1: github for timelogging
I've got to keep track of what I work on. The company I work for (Nelen & Schuurmans) is pretty much focused on projects, so that's what you should book your hours on. This is both for billing to clients and for internal bookkeeping: projects should be profitable, ideally, so we need to keep track of it. Now... how to do this? I fill in my hours two or three times during the month. And my memory isn't that good that I remember everything. So I look in my agenda for free days, meetings, that sort of stuff. But the majority of my work isn't in my agenda, it is in code. And the code... is in github, mostly. So what I do when filling in my hours is looking at the github timeline. See https://github.com/reinout, at the bottom is my contribution activity. That tells me enough on what I did in the last week. A different view is gitspective, see for instance my timeline. It gives you a different timeline, better for filling in your hours than github's. Apart from one detail: it misses the private repositories you worked on. And our Django sites are all private because of … -
Logging time, part 2: gtimelog on the commandline
Using github for timelogging is fine, but I longed back to the days when I used a hacked-up of gtimelog that worked on the commandline. I looked in my private git repository with my old subversion stuff and found it. Why gtimelog? Well, in my case, on the commandline, it works quite well. Type in tl weblog on the commandline when I've written a blog entry. Type in tl ror_export when I've worked on that particular project. I've hooked up commandline completion. The end result is a timelog.txt file with a simple line-based format: 2013-04-16 09:36: arrived** 2013-04-16 10:08: compu 2013-04-16 10:31: omnifocus 2013-04-16 11:15: neerslagradar 2013-04-16 11:37: email_en_newsgroups 2013-04-16 11:50: email_en_newsgroups 2013-04-16 12:30: lizard_unbillable 2013-04-16 13:15: lunch** You can modify it afterwards if needed. Lightweight. I get a daily or weekly report out of it like this: Blokkendoos 3 hours 24 min Compu 32 min Email_en_newsgroups 35 min Lizard_unbillable 2 hours 6 min Neerslagradar 44 min The regular gtimelog requires gtk, which isn't handy on OSX. On debian/ubuntu you can apt-get install it. You get a window-based interface that way and can click entries and have a constant overview and so. That said, I hacked up a modified version … -
Django and RequireJS
Until very recently, I was very happy with [django-compressor](http://django-compressor.readthedocs.org/en/latest/). It does a great job of combining and minifying static media files, specifically JavaScript and CSS files. It will manage compilation, allowing you to use, for example, SASS and CoffeeScript. Not that I do. But, for me, the best part was the cache invalidation. By combining JavaScript (or CSS) into files that get named according to a hash of their contents, it's trivial for clients to not have an old cached JS or CSS file. However, recently I have begun using [RequireJS](http://requirejs.org). This enables me to declare dependencies, and greatly simplify the various pages within my site that use specific JavaScript modules. But this does not play so well with django-compressor. The problem lies with the fact that there is no real way to tell RequireJS that "instead of ``js/file.js``, it should use ``js/file.123ABC.js``", where ``123ABC`` is determined by the static files caching storage. RequireJS will do optimisation, and this includes combining files, but that's not exactly what I want. I could create a built script for each page that has a ``require()`` call in it, but that would mean ``jQuery`` etc get downloaded seperately for each different script. I have … -
Django for Web Prototyping
Or how to use the benefits of Django template system during the PSD to HTML phase There are two main approaches to start designing a new project – Photoshop mock-up or an HTML prototype. The first one is more traditional and well established in the web industry. The second one is more alternative and (maybe)modern. I remember a video of Jason Fried from 37 Signals where he talks about design and creativity. You can see it at http://davegray.nextslide.com/jason-fried-on-design. There he explains how he stays away from the Photoshop in the initial phase to concetrate on the things that you can interact with instead of focusing on design details. I am not planning to argue which is the better method, the important thing here is that sooner or later you get to the point where you have to start the HTML coding. Unfortunately frequently this happens in a pure HTML/CSS environment outside of the Django project and then we waste some extra amount of time to convert it to Django templates. Wouldn’t be awesome if you can give the front-end developers something that they can install/run with a simple command and still to allow them to work in the Django environment … -
Generating NCX files with Python
With the help of fellow Python developer Matt Harrison's excellent Ebook Formatting: KF8, Mobi & EPUB, we managed to create pretty decent looking Kindle and ePub versions of Two Scoops of Django. One of many things we did was focus on providing an excellent table of contents. Of course we provided one inside the content of the book, but much like the PDF version we also provided one that various ebook readers can display in sidebars or drop down menus. Unfortunately, building this navigation isn't well documented (except for Matt's book), and I've yet to see any good ways to generate it via code. Which is why I present the following code. It looks at the HTML that KindleGen and ePub generators demand and pulls from it a chapter-based table of contents. Then constructs a .ncx file, which is what ebook readers use to generate the sidebar/dropdown table of contents. Our requirements: Jinja2 Django BeautifulSoup4 And now the code: #!/usr/bin/python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup from django.utils.text import slugify from jinja2 import Template TEMPLATE = Template("""<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en"> <head> <!-- The content of dtb:uid must … -
Generating NCX files with Python
With the help of fellow Python developer Matt Harrison's excellent Ebook Formatting: KF8, Mobi & EPUB, we managed to create pretty decent looking Kindle and ePub versions of Two Scoops of Django. One of many things we did was focus on providing an excellent table of contents. Of course we provided one inside the content of the book, but much like the PDF version we also provided one that various ebook readers can display in sidebars or drop down menus. Unfortunately, building this navigation isn't well documented (except for Matt's book), and I've yet to see any good ways to generate it via code. Which is why I present the following code. It looks at the HTML that KindleGen and ePub generators demand and pulls from it a chapter-based table of contents. Then constructs a .ncx file, which is what ebook readers use to generate the sidebar/dropdown table of contents. Our requirements: Jinja2 Django BeautifulSoup4 And now the code: #!/usr/bin/python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup from django.utils.text import slugify from jinja2 import Template TEMPLATE = Template("""<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en"> <head> <!-- The content of dtb:uid must … -
Bundling dependencies
This post is about maintenance programming and the issue of Open Source dependencies that may need customising. It compiles some of my current thoughts, but I'm also eager to find out what other people do. 3 approaches to dependencies Pure dependency The source code of the dependency does not become a part of your project in any way. For a web project with Python and virtualenv/pip, you would just list the project name and version in requirements.txt, and it will be installed when you deploy your project. This is by far the easiest approach to dependencies. Forked dependency You create a fork of the library (usually hosted publicly, but not necessarily) and add to it the changes you need. You then use this fork from your main project. This is done either in the hope that bug fixes and feature additions that you make will be merged into the original, so that you won't have to maintain your fork forever, or with the aim of keeping your changes small enough that it will always be easy to merge in fixes from upstream. Bundled dependency You take a copy of the library, and include it directly into your own source code, … -
Django 1.5 on Webfaction
The setup of a Django application on Webfaction is really easy using their one-click-installer. But this setup is really static and surely not the best option to use for Django. Luke Plant wrote about setting up Django with gunicorn on Webfaction in his blog, I will write about setting up Django 1.5 with Apache and mod_wsgi without the Django one-click-installer but the mod_wsgi one (mod_wsgi 3.4 / Python 2.7). The setup won't be the fastest Django setup in the world, but it will work. It's basically an update for my old blog post covering Django 1.3: Set up a mod_wsgi application and create a website in the Webfaction control panel. Log into shell and goto your newly created app. Create a virtualenv and a folder for your project files (maybe you want to check out from a VCS), activate the virtualenv and install Django an whatever you need. Edit the default wsgi.py create by the django-admin.py startproject command: """ WSGI config for tools_project project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. … -
Django 1.5 on Webfaction
The setup of a Django application on Webfaction is really easy using their one-click-installer. But this setup is really static and surely not the best option to use for Django. Luke Plant wrote about setting up Django with gunicorn on Webfaction in his blog, I will write about setting up Django 1.5 with Apache and mod_wsgi without the Django one-click-installer but the mod_wsgi one (mod_wsgi 3.4 / Python 2.7). The setup won't be the fastest Django setup in the world, but it will work. It's basically an update for my old blog post covering Django 1.3: Set up a mod_wsgi application and create a website in the Webfaction control panel. Log into shell and goto your newly created app. Create a virtualenv and a folder for your project files (maybe you want to check out from a VCS), activate the virtualenv and install Django an whatever you need. Edit the default wsgi.py create by the django-admin.py startproject command: """ WSGI config for tools_project project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. … -
Django 1.5 on Webfaction
The setup of a Django application on Webfaction is really easy using their one-click-installer. But this setup is really static and surely not the best option to use for Django. Luke Plant wrote about setting up Django with gunicorn on Webfaction in his blog, I will write about setting up Django 1.5 with Apache and mod_wsgi without the Django one-click-installer but the mod_wsgi one (mod_wsgi 3.4 / Python 2.7). The setup won't be the fastest Django setup in the world, but it will work. It's basically an update for my old blog post covering Django 1.3: Set up a mod_wsgi application and create a website in the Webfaction control panel. Log into shell and goto your newly created app. Create a virtualenv and a folder for your project files (maybe you want to check out from a VCS), activate the virtualenv and install Django an whatever you need. Edit the default wsgi.py create by the django-admin.py startproject command: """ WSGI config for tools_project project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. … -
A whole load of Kickstarting
When I launched my Kickstarter campaign, I didn't quite expect this level of response... It's an odd thing, the internet. Back when I was just starting out doing freelance work - at the ripe old age of fifteen - I remember my mother being slightly bemused that people on the internet were giving me money. Of course, that was for work I had already completed, but in this modern age, it's now possible to raise money before you've even started. My Kickstarter campaign was a simple request - I have some free time, a specific project to build, and a pretty good idea of how to build it. Why not see if the community would contribute? NoteI almost added a £20,000 stretch goal to remove MySQL support entirely. Almost. Oh, how they did. The Kickstarter closed at a whopping £17,952 - 718% of my original £2,500 request. Not only that, but it was funded in 65 minutes and my highest stretch goal (£7,000) was reached in four hours. That Friday was one of the most surreal days of my life - watching the Kickstarter page and Twitter as both donations and messages of support came streaming in. 507 people contributed … -
A helper script for runserver
My Django runserver shortcut script This is a little shell script I save as rs, put on my path, and use as a shortcut to start the Django development server. It has several features that make me more productive: It’s shorter to type than python manage.py runserver. It recognizes what project I’m in and runs many of them on different ports. It opens the web site’s front page in my browser. Running my most important projects on separate ports has a couple of advantages: I can run several simultaneously. My browser can differentiate the projects. When everything runs at localhost:8000, my browser might cache a file like style.css and have no way of knowing when I switch projects and style.css is completely different. If one project is at localhost:8001 and the other is at localhost:8002, the cache keeps them separate. It opens the current site in my browser (after giving the server a few seconds to start) because that’s typically what I do next anyway, and it saves me having to keep track of which project uses which port. If I already have the site open in my browser, I just pass “.” as the first command line argument and … -
Announcing WSGI X-Sendfile: High-Performance File Transfer for Python/WSGI Applications
I'm pleased to announce the first public release of WSGI X-Sendfile, a library that lets your Python/WSGI application serve static files via your Web server.Modern Web servers like Nginx are generally able to serve files faster, more efficiently and more reliably than any Web application they host. These servers are also able to send to the client a file on disk as specified by the Web applications they host. This feature is commonly known as X-Sendfile.This simple library makes it easy for any WSGI application to use X-Sendfile, so that they can control whether a file can be served or what else to do when a file is served, without writing server-specific extensions. Use cases include:Restrict document downloads to authenticated users.Log who’s downloaded a file.Force a file to be downloaded instead of rendered by the browser, or serve it with a name different from the one on disk, by setting the Content-Disposition header.This code has been used in production for three years, but is now being released as beta in case there are bugs that haven't become evident in our systems.Get it while it's hot! -
Announcing WSGI X-Sendfile: High-Performance File Transfer for Python/WSGI Applications
I'm pleased to announce the first public release of WSGI X-Sendfile, a library that lets your Python/WSGI application serve static files via your Web server. Modern Web servers like Nginx are generally able to serve files faster, more efficiently and more reliably than any Web application they host. These servers are also able to send to the client a file on disk as specified by the Web applications they host. This feature is commonly known as X-Sendfile. This simple library makes it easy for any WSGI application to use X-Sendfile, so that they can control whether a file can be served or what else to do when a file is served, without writing server-specific extensions. Use cases include: Restrict document downloads to authenticated users. Log who’s downloaded a file. Force a file to be downloaded instead of rendered by the browser, or serve it with a name different from the one on disk, by setting the Content-Disposition header.This code has been used in production for three years in our Django application, but is now being released as beta in case there are bugs that haven't become evident in our systems. Get it while it's hot! -
Progress Report for March 26th
Reflections on my progress and plans*Update: I had thought I had previously published this post on March 26th, but obviously I did not.The last week has been hectic, but quite productive for Team Django. The team has created a new version of our project poster. Additionally, we have been working on ticket #19224, and creating a rough version of our final presentation slides. A piece of interesting news is the Schema Migrations for Django kickstarter. Andrew Godwin, creator and maintainer of Django South, has proposed adding schema migrations to the Django core. Yes, this isn't an "official" Django proposal. Yes, he did get the approval of the other core contributors. He has raised an incredible amount of money, $23,000 as of March 26th. -
Satchmo 0.9.2 Released
Satchmo 0.9.2 is released. This release of satchmo includes many updates and improvements. -
Editar y traducir inline en Django fácilmente
Desde Yaco nos traen las aplicaciones pluggables django-inlinetrans y django-inplaceedit que permiten editar traducciones de templates y objetos de nuestros modelos desde el frontend de nuestro proyecto... -
Dropbox file upload handler for django
Dropbox announced new pro plans last week and some accounts have had their storage size doubled. Wouldn't it be wonderful if we could upload all our files to dropbox from our django webapp? In this post, I write a custom file upload handler that will upload files from our application to dropbox. Let us see how to use the custom file upload handler. Install the Dropbox Python SDK before you setup your django app to handle the file uploads. In your settings.py, add the following attributes (with the values filled): DROPBOX_APP_KEY = "" DROPBOX_APP_SECRET_KEY = "" DROPBOX_APP_ACCESS_TOKEN = "" DROPBOX_APP_ACCESS_TOKEN_SECRET = "" # Optional values below # The folder where you want the files uploaded. # Example: /Public or / DROPBOX_FILE_UPLOAD_FOLDER = "" # The value below may be either 'app_folder' or 'dropbox' DROPBOX_ACCESS_TYPE = "" The DROPBOX_APP_KEY and DROPBOX_APP_SECRET_KEY are provided to you when you create a new dropbox app. Fetching the access token and access token secret is outside the scope of this blog post but you can follow the Getting Started Guide until the Get an access token section and then paste the access token key and secret in the DROPBOX_APP_ACCESS_TOKEN and DROPBOX_APP_ACCESS_TOKEN_SECRET attributes respectively. Add the … -
Introduction to Django Selenium Testing
-
Python deployment using fabric and pip
I've spent a not insignificant amount of time working on a deployment function for within my ``fabfile.py`` (the configuration file used by [Fabric](http://fabfile.org)). It's well worth the investment, as being able to deploy with a single command (potentially to many servers) is not only faster, but much less prone to human error. Currently, I'm using [Mercurial](http://mercurial.selenic.com) as my source control. I'm also using it for deployment, but I'd like to get away from that. My deployment process looks something like this: 1. Ensure the local repository has no uncommitted changes. 2. Ensure the ``requirements.txt`` file is exactly the same as the output from ``pip freeze``. 3. Copy our public key to the remote server, for the user ``www-data``, if it is not already installed there. 4. Create a [``virtualenv``](https://pypi.python.org/pypi/virtualenv) in the desired location on the server, if there is not one already there. 5. Ensure ``mercurial`` is installed on the server. 6. Push the local repository to the remote server. This will include any subrepositories. I do a little bit of fancy magic to ensure the remote subrepositories exist. 7. Update the remote server's repository to the same revision as we are at locally. This means we don't necessarily need … -
Go Open Data
What started as a brief conversation between myself and Michael Druker almost a year ago has come to life. On Saturday, May 11th people from Windsor to Ottawa are going to come together at the University of Waterloo School of Pharmacy for GO Open Data, a one day conference. The conference aims to bring together people from across Ontario and across the various interests related to open data to enjoy 8 talks, 2 panels, and an exhibition called Open Data Alley. Citizens, journalists, developers, administrators, CIOs, librarians, different people from all the areas connected to this fusion of technology and policy will be in attendance. That alone will make for an exciting day. It is thanks to the many partners from the Region of Waterloo, the City of Waterloo and the University of Waterloo that such a small idea has become so successful. We have amazing speakers like Ontario Information and Privacy Commissioner Dr. Ann Cavoukian, and up and coming speakers like James McKinney from Open North in Montreal. You can hear an interview with Dr. Cavoukian on the lawful access episode of Jessie Brown's Search Engine podcast. The rest of the schedule can be found online: http://go-opendata.ca/ The conference …