Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Python and OS X Lion
-
Convention Over Configuration: Django Settings
I've been working with Django for over five years. Even though **I don't consider myself as a programmer**, one of the advantages I seem to have over less experienced Django developers is that I've developed (together with <a href="http://www.syneus.fi/" title="Syneus Solutions -- In Finnish">our team</a>) strong conventions on how I work. This makes developing faster and generally more enjoyable. Conventions are a tool for efficient workflow and to help read and understand code by other people better. Like so many tools, conventions too can be taken to extremes to the point when then they become magic (Rails, anyone), which in Python community is <a href="http://www.reddit.com/r/Python/comments/ex54j/seeking_clarification_on_pylonsturbogearspyramid/c1bo1v5">considered a bad practice</a>. The Python community has a name for code that feels right: that kind of code is _pythonic_. Good, pythonic conventions are logical and easy to remember but also explicit. In other words good conventions should make sense when you see them first time. Django has many documented conventions (like that models should live in `models.py` and views in `views.py`) and even <a href="https://docs.djangoproject.com/en/1.3/internals/contributing/#coding-style">coding guidelines</a> but there are many places that could use more stronger or better ones. This article is first in a series of discussing conventions related to Django. My goal … -
Convention Over Configuration: Django Settings
This is a first article in a series about DRY and pythonic conventions for Web development with Django. The goal is to share and discuss common problems in everyday Django development where there is no documentation nor an obvious way of do it. -
How to always exclude specific Django applications from unit testing
Sometimes your Django project will include applications whose unit tests will never pass. In this post, I will explain a quick fix for this, and, probably more usefully, try to explain how and why I developed the code. -
How to always exclude specific Django applications from unit testing
Sometimes your Django project will include applications whose unit tests will never pass. In this post, I will explain a quick fix for this, and, probably more usefully, try to explain how and why I developed the code. -
Disabling South Migrations
It is often handy to disable (either temporarily or permanently) South migrations for an app. “Disable” in this context means preventing an app’s migrations from being executed so that the app is managed via syncdb while in this state. A couple scenarios where this could be useful… -
An alternative RapidSMS router implementation (with Celery!)
We've been using RapidSMS, a Django-powered SMS framework, more and more frequently here at Caktus. It's evolved a lot over the past year-- from being reworked to feel more like a Django app, to merging the rapidsms-core-dev and rapidsms-contrib-apps-dev repositories into a single codebase (no more submodules!), to finally becoming installable via pypi. The "new core" ... -
An alternative RapidSMS router implementation (with Celery!)
We've been using RapidSMS, a Django-powered SMS framework, more and more frequently here at Caktus. It's evolved a lot over the past year-- from being reworked to feel more like a Django app, to merging the rapidsms-core-dev and rapidsms-contrib-apps-dev repositories into a single codebase (no more submodules!), to finally becoming installable via pypi. The "new core" is in a great state now and is much easier to work with. However, one particular aspect of RapidSMS, the route process, has always been complicated and confusing to deal with. Tobias began the conversation on this issue after returning from a 6-week long UNICEF project in Zambia. He summarized the route process like so: -
Python and Django class/hackathon!
The Los Angeles Python community (LA Django and LA PyLadies) is meeting in Santa Monica on July 23rd to teach Django and hack on all things Python on Saturday, July 23rd. The day will start with a Django class based on the official Django tutorial, then turn into a general hackathon, and finish up with lighting talks.Leading the event is noted Pythonista Katharine Jarmul. As Katharine is giving the talk on web scraping at DjangoCon US, I'm hoping we can get her to give a lightning talk on the subject.Learning DjangoSandy Strong will lead the effort to teach people the fundamentals of Django. Besides all things Django and devops, Sandy is presenting the testing talk at DjangoCon US. And if that isn't good enough for you, she won't be alone teaching - there will be a bunch of us developers experienced with Django there to to provide her with support.Even if you already know Django, please come and hang out for the first half! You can either help out others or work on your own project.Hacking Python and DjangoThe second half of the day will be about working on whatever you want. If you are new to Django and want to finish … -
Creantbits un 15 de juliol
Ahir divendres 15 hi hagué una nova edició del creantbits. Aquesta vegada enlloc de que la inscripció es fes en un comentari al blog, ho ferem amb una aplicació creada ad-hoc i que serví per experimentar amb un hosting de Python. El hosting va caure un pic en el procés d'inscripció (després de tot encara està en beta), però la gent d'Eldarion va respondre i en poques hores estava una altra vegada operatiu. L'aplicació en si crec que ha respost bastant bé, tot i estar feta en quatre potades. Ha permés a la gent que s'havia inscrit prest i després no ha pogut venir, fer-ho saber ràpidament i comunicar-ho al següent de la llista d'espera. Tot d'una que tengui una estona més miraré de documentar l'aplicació (que el codi ja hi està) i posar-ho a bitbucket per tal que si hi ha més gent que s'animi entre tots poguem fer un bon programa de gestió d'events. De l'event en sí poca cosa a dir, la sala plena d'amics, gent que ja coneixia personalment i gent que he pogut desvirtualitzar per primera vegada. Però la part important és amics, això fa que parlar en públic sigui molt menys estressant i també … -
Debian init script for virtualenv'd gunicorn_django
I recently moved my projects to gunicorn and needed init scripts. Here's what I'm currently using. I have the gunicorns running behind nginx, so you might want to tweak the IP and PORT settings. It might also be nice to use start-stop-daemon. #! /bin/sh ### BEGIN INIT INFO # Provides: gunicorn-initscript # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $nginx # Default-Start: 30 2 3 4 5 # Default-Stop: 70 0 1 6 # Short-Description: virtualenv + gunicorn + nginx debian init script # Description: virtualenv + gunicorn + nginx debian init script ### END INIT INFO # Author: Nicolas Kuttler <hidden> # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script. # # Enable with update-rc.d gunicorn-example start 30 2 3 4 5 . stop 70 0 1 6 . # (parameters might not be necessary, test) # Do NOT "set -e" PROJECT=/path/to/project/ VIRTUALENV=/path/to/virtualenv PORT=8888 LOGDIR=/var/log/gunicorn/ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/bin:/usr/bin USER=www-data GROUP=www-data IP=127.0.0.1 WORKERS=5 # I am lazy and just call the init script gunicorn-project NAME=`basename $0` DESC=$NAME LOGFILE="$LOGDIR$NAME.log" PIDFILE="$PROJECT$NAME.pid" CMD="gunicorn_django --user=$USER --group=$GROUP --daemon … -
Debian init script for virtualenv'd gunicorn_django
I recently moved my projects to gunicorn and needed init scripts. Here's what I'm currently using. I have the gunicorns running behind nginx, so you might want to tweak the IP and PORT settings. It might also be nice to use start-stop-daemon. Raw #! /bin/sh ### BEGIN INIT INFO # Provides: gunicorn-initscript # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $nginx # Default-Start: 30 2 3 4 5 # Default-Stop: 70 0 1 6 # Short-Description: virtualenv + gunicorn + nginx debian init script # Description: virtualenv + gunicorn + nginx debian init script ### END INIT INFO # Author: Nicolas Kuttler <hidden> # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script. # # Enable with update-rc.d gunicorn-example start 30 2 3 4 5 . stop 70 0 1 6 . # (parameters might not be necessary, test) # Do NOT "set -e" PROJECT=/path/to/project/ VIRTUALENV=/path/to/virtualenv PORT=8888 LOGDIR=/var/log/gunicorn/ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/bin:/usr/bin USER=www-data GROUP=www-data IP=127.0.0.1 WORKERS=5 # I am lazy and just call the init script gunicorn-project NAME=`basename $0` DESC=$NAME LOGFILE="$LOGDIR$NAME.log" PIDFILE="$PROJECT$NAME.pid" CMD="gunicorn_django --user=$USER --group=$GROUP … -
Debian init script for virtualenv'd gunicorn_django
I recently moved my projects to gunicorn and needed init scripts. Here's what I'm currently using. I have the gunicorns running behind nginx, so you might want to tweak the IP and PORT settings. It might also be nice to use start-stop-daemon. Raw #! /bin/sh ### BEGIN INIT INFO # Provides: gunicorn-initscript # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $nginx # Default-Start: 30 2 3 4 5 # Default-Stop: 70 0 1 6 # Short-Description: virtualenv + gunicorn + nginx debian init script # Description: virtualenv + gunicorn + nginx debian init script ### END INIT INFO # Author: Nicolas Kuttler <hidden> # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script. # # Enable with update-rc.d gunicorn-example start 30 2 3 4 5 . stop 70 0 1 6 . # (parameters might not be necessary, test) # Do NOT "set -e" PROJECT=/path/to/project/ VIRTUALENV=/path/to/virtualenv PORT=8888 LOGDIR=/var/log/gunicorn/ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/bin:/usr/bin USER=www-data GROUP=www-data IP=127.0.0.1 WORKERS=5 # I am lazy and just call the init script gunicorn-project NAME=`basename $0` DESC=$NAME LOGFILE="$LOGDIR$NAME.log" PIDFILE="$PROJECT$NAME.pid" CMD="gunicorn_django --user=$USER --group=$GROUP … -
Debian init script for virtualenv'd gunicorn_django
I recently moved my projects to gunicorn and needed init scripts. Here's what I'm currently using. I have the gunicorns running behind nginx, so you might want to tweak the IP and PORT settings. It might also be nice to use start-stop-daemon. #! /bin/sh ### BEGIN INIT INFO # Provides: gunicorn-initscript # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $nginx # Default-Start: 30 2 3 4 5 # Default-Stop: 70 0 1 6 # Short-Description: virtualenv + gunicorn + nginx debian init script # Description: virtualenv + gunicorn + nginx debian init script ### END INIT INFO # Author: Nicolas Kuttler <hidden> # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script. # # Enable with update-rc.d gunicorn-example start 30 2 3 4 5 . stop 70 0 1 6 . # (parameters might not be necessary, test) # Do NOT "set -e" PROJECT=/path/to/project/ VIRTUALENV=/path/to/virtualenv PORT=8888 LOGDIR=/var/log/gunicorn/ # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/bin:/usr/bin USER=www-data GROUP=www-data IP=127.0.0.1 WORKERS=5 # I am lazy and just call the init script gunicorn-project NAME=`basename $0` DESC=$NAME LOGFILE="$LOGDIR$NAME.log" PIDFILE="$PROJECT$NAME.pid" CMD="gunicorn_django --user=$USER --group=$GROUP --daemon … -
Lightning talk: Hacking EuroPython.org (with Django)
I gave a lightning talk yesterday at the EuroPython conference about my little MyEuroPython mashup. The intention of the talk was not to promote the site but to raise a conversation about how to make better conference websites (and especially EuroPython.org). Main points of my presentation were that conferences are about communication and interaction. Current EuroPython.org does not give any tools for that, and it would be great to have something more 2.0 for the site. For example: Simple site structure with good (live)search Registration and personal preferences using OpenID Allow commenting of sessios Provide a personalizable timetable (that is useful for example when using a mobile phone) Free the data; RSS feeds (and possibly other APIs?)from everything Aggregate blog entries, images, links to the main site Good thing was, there was talk about the presentation afterwards, and we actually volunteered for doing the EuroPython.org with Django next year. Hopefully the discussion lives on! » Comment this entry -
Offline Development With Django
Coming to Django from the PHP-world, running a local development server (as opposed to Apache or a full LAMP-machine set up for just testing) and doing real offline development is something that takes a little bit of learning. After two years of active development with Django, I’d like to share some of my learnings. Why Offline? There are many benefits for developing your site someplace other than the same server which powers the site. I’m sure most of us do development this way. Generally speaking offline development could mean any development that doesn’t happen on the production server. The meaning for offline development in this article is more literal: by offline I mean literally offline, that is without [requiring] a connection to the Web. A well configured development environment helps you write better code efficiently — anywhere. On a side note, don’t blame me if you end up coding Django your whole winter vacation at an idyllic remote cottage ;) Best Practices In the same way that Django lets you separate models, templates and views, it also lets you easily separate production and testing environments. Django also offers several tools for local development, such as the built in Web server … -
Being Robust
Writing software that interacts with other peoples code is hard. To be robust, Postel’s Law suggests to be conservative in what you do; be liberal in what you accept from others. What follows is is a good example of what happens if you don’t. When I posted my first Flickr pictures in 2005, Flickr photo_ids were counted in millions. Year later, they were in hundreds of millions. December last year, they topped 2.1 billion, which also happens to be the maximum value of signed integer type in some programming languages. Here are some examples from my own pictures and their photo_ids from Flickr: 6,029,771 March 2005 289,332,856 November 2006 2,165,862,620 December 2007 After reading about someones problems with the 2,1 billion mark, I reviewed my own code. When I first integrated Flickr API to my homemade photo application in early 2006, I was smart enough to use unsigned integers (that would get me as far as 4,294,967,295) as field type for photo_id but not smart enough to read API documentation that explicitly advices to treat photo_id and other IDs as strings, because “format of the IDs can change over time, so relying on the current format may cause you problems … -
The Global Django
One thing that annoys me in many US-based software projects is the narrow mindness of the developers who seem to forget that there is life outside of the US, too. Django has been a very international project from the day one, with admin interface translated to 43 languages and the contrib.localflafor full of great localized stuff like validators for Finnish social security number etc. After Adrian’s official announcement of the worldwide Django sprint (that will be held on Friday, Sept. 14, 2007) there has been a steady flow of volunteers adding their names on the wiki page. As I write this, over hundred volunteers from 26 countries have signed up for the event. It’s just amazing. I wish more open source projects would have as great community that Django has. And greetings to everyone who is attending the sprint next Friday — let’s have fun! :) -
State machines for web development
I'm using FSM a lot, both implicitly and explicitly. I like using them in JavaScript, I'd be crazy without them. On my Django backends, FSMs care for everything on the website to be converted, cleaned up and be fine. The moment you understand FSM is a moment of Truth and Enlightment. -
Foreign key to Django CMS page …
… how to make usable drop-downs with Django CMS pages Problem: some times when you create custom applications or plugins for Django CMS you need a property that connects the current item to a page in the CMS. Nothing simple than this – you just add a ForeignKey in your model that points to the [...] -
An alternative RapidSMS router implementation (with Celery!)
We've been using RapidSMS, a Django-powered SMS framework, more and more frequently here at Caktus. It's evolved a lot over the past year-- from being reworked to feel more like a Django app, to merging the rapidsms-core-dev and rapidsms-contrib-apps-dev repositories into a single codebase (no more submodules!), to finally becoming installable via pypi. The "new core" ... -
Caktus Lightning Talk Lunches
Last month we hosted the first talk in our new Caktus Lightning Talk Lunch series. We started this series to get together and learn about new projects, different applications, and interesting topics that the Caktus team has been working on. Lunch was provided from Buns in Chapel Hill and Mark Lavin gave the first talk. Mark presented ... -
Caktus Lightning Talk Lunches
Last month we hosted the first talk in our new Caktus Lightning Talk Lunch series. We started this series to get together and learn about new projects, different applications, and interesting topics that the Caktus team has been working on. Lunch was provided from Buns in Chapel Hill and Mark Lavin gave the first talk. -
Extending different base template for ajax requests in Django
While there are different ways to specify what should be rendered what should server return when ajax request is performed, using yesno template filter can be simplest. This can be especially useful in situations when using without javascript should fail gracefully or when working with existing views. {% extends request.is_ajax|yesno:“base_ajax.html,base.html” %} For this to work, django.core.context_processors.request should be installed in TEMPLATE_CONTEXT_PROCESSORS. -
Caching websites with Django and Memcached…
… memcached installation, django configuration and how to use it for your website After Caching web sites and web applications and When to use caching for web sites its time for a little sample. This sample shows the usage of Memcached for server-side application cache. The installation part is taken from my Ubuntu so it [...]