Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
I can haz a question (or five)?
So... people have noticed that I have this habit at conferences. It's been lampooned and questioned online; I've also been asked about it in person. I ask questions. A lot of questions. More often than not, I ask the first question at every talk I attend. And people think it's weird. However, there is method in my madness. Back in the day, I was a Physics undergrad student who migrated to the Computer Science department to do my Honours degree. To make some use of my undergrad qualifications, my Honours thesis was revolved around a computational physics problem. Although my thesis topic was strictly computer science, it wasn't one of the research foci of the department. Half way through the year, Honours students were required to give a presentation to the faculty describing their work and their progress. The presentation was assessed, and formed a major part of the mid-term mark for the course. A component of the mark for that assessment (I think it was 10%) was allocated to how well the student answered questions. So, I diligently gave my presentation, describing the problem I was addressing, and how I was going to address it. My slides all worked, … -
"La guía definitiva de Django"
Hace unos días recibimos dos ejemplares de La guía definitiva de Django que nos enviaron nuestros amigos de Anaya Multimedia. Se trata del primer libro publicado en español sobre Django y es la traducción al español de "The Definitive Guide to Django"... La guía definitiva de Django" contiene todos los capítulos de "The Definitive Guide to Django" y resulta más amena que ésta para aquellos que no dominan tanto el inglés o prefieren leerla en castellano... -
Getting Started with virtualenv (Isolated Python Environments)
Like South, virtualenv is a helper utility that I put off using for too long. Looking back, it is so easy to get up and running (just like South, see below) that there is no reason for you to hold off like I did. In a nutshell, virtualenv is a tool for creating isolated Python [...] -
Provisioning a new Ubuntu server for Django
I've been a long-time satisfied user of Webfaction, but recently I've had a strong urge to move to VPS hosting so that I can have greater control over the environment. After some research, I went with Rackspace Cloud because of the incredibly cheap low-end options. My site doesn't use a huge amount of bandwidth, so Rackspace looks to be the most feature-packed and still cost-effective option. A friend of mine, Kevin Whitaker, recently posted a great article about getting up and running with Django in a server environment for testing or production. He used Ubuntu, Postgres, Nginx, and FastCGI to make up his stack. I've never set up Nginx before, so his post was a great help in getting Nginx configured. My stack is slightly different, however, since I prefer to use Gunicorn instead of FastCGI and I use supervisord to manage my processes. I also use virtualenv to manage dependencies like Django itself and psycopg2. I'm including my install notes below so that I can provide a complete picture of one way of provisioning a new server from build to deploy. My site is relatively low-traffic, so I'm not going to go into postgres tweaking, connection pooling, caching, etc. … -
Selenium Unit Test Reuse
Yesterday, one of the QA guys at work approached me with a question that turned out to be much more interesting to me than I think he had planned. He's been doing some unit testing using Selenium, exporting his test cases to Python. His question was this: how can I run the same unit tests using multiple browsers and multiple target servers? I'm pretty sure he expected a simple 3-step answer or something like that. Instead, he got my crazy wide-eyed "ohhh... that's something I want to experiment with!" look. I started rambling on about inheritance, dynamic class creation, and nested for loops. His eyes started to look a little worried. He didn't really appreciate the nerdy lingo that much. I told him to pull up a chair and get comfortable. Since I already had some other work I needed to pay attention to, I didn't want to spend too much time trying to figure out a good way to solve his problem. After about 20 minutes of devilish chuckles and frantic rustling through Python documentation, I came up with the following code: from types import ClassType from selenium import selenium import unittest IPS = ['192.168.0.1', '192.168.0.2'] BROWSERS = ['safari', … -
Selenium Unit Test Reuse
Yesterday, one of the QA guys at work approached me with a question that turned out to be much more interesting to me than I think he had planned. He's been doing some unit testing using Selenium, exporting his test cases to Python. His question was this: how can I run the same unit tests using multiple browsers and multiple target servers? I'm pretty sure he expected a simple 3-step answer or something like that. Instead, he got my crazy wide-eyed "ohhh... that's something I want to experiment with!" look. I started rambling on about inheritance, dynamic class creation, and nested for loops. His eyes started to look a little worried. He didn't really appreciate the nerdy lingo that much. I told him to pull up a chair and get comfortable. Since I already had some other work I needed to pay attention to, I didn't want to spend too much time trying to figure out a good way to solve his problem. After about 20 minutes of devilish chuckles and frantic rustling through Python documentation, I came up with the following code: from types import ClassType from selenium import selenium import unittest IPS = ['192.168.0.1', '192.168.0.2'] BROWSERS = ['safari', … -
Beginning Django Development
Oddly, I have had four different people ask me about the best way to begin aDjangoproject or setup their system to make it easy to develop with Django.Since I've now given my response via email so many times, I figure I might as well broadcast it and hopefully this will help others as wellMy assumptions:Using Linux (or a Unix machine)Single developer with root access (quite possibly a laptop)Knowledge of DVCSes (e.g. git / hg / bzr )What we will do is create a private binary directory and anotherPythonmodules. Then take a checkout of the two most important Django projects, and make them work.First: create your user$ sudo adduser newbie $ ssh localhost -l newbie $ whoami newbieThen we want to create some local bin and lib directories. First the binary directory$ mkdir ~/bin# OnUbuntu/Debian, this will automatically be in your PATH the next time you loginAnd now a local directory for our various libraries$ mkdir -p ~/lib/python $ echo "PYTHONPATH=~/lib/python:" >> ~/.bashrc $ echo "export PYTHONPATH" >> ~/.bashrcThis will add that directory to our Python path. If you happen to also use another language you can put things into ~/lib/ruby, ~/lib/perl as appropriate$ mkdir ~/Projects $ cd ~/ProjectsHere is where … -
Deploying Django
It's been a while between posts, and also between Django projects, but coincidentally with the release of 1.2 I've found an excuse to work with Django again, and have decided to release my own Django deployment library based on fabric called woven. More on that in a minute. Deployment of Django projects has always been a bit harder than it should be. I understand why Django hasn't gone down the -
Django model definitions can’t be reloaded
I spent way too much time this evening figuring this out. If you have a models file like this (artificial, but play along): from django.db import models from random import random rand_val = random() class MyModel(models.Model): r = rand_val After you import MyModel in some other module, you can’t re-load the class definition of MyModel. [...] -
Getting Started with South (Django Database Migrations)
The very bare bones steps to getting up and running with South for your Django database migrations. -
Using virtualenvwrapper to start processes and swap config files
I do my Django development work locally on OS X, so I have several different daemons installed on my machine. I used to keep Postgres, MySQL, lighttpd, memcached, and more set up to autostart and run continuously, but I didn't like the burden on performance (real or imagined). Also, I switch between projects frequently and I often need to switch config files based on the project I'm about to work on. My solution is to use the end-user customization hooks that Doug Hellmann's excellent virtualenvwrapper provides. If you're not familiar with virtualenvwrapper, it makes it easy to manage your virtualenvs in one place and switch between them quickly and conveniently. The project provides several scripts that are meant to be added to by the end-user to customize behavior. Configuration For my configuration files, I create multiple versions with the changes needed for each project, and I then create a symlink to the version I want at the moment. For example, with lighttpd I'll create an /etc/lighttpd/project-a.conf and an /etc/lighttpd/project-b.conf, and then create a symlink called /etc/lighttpd/lighttpd.conf that points to the one I need. In OS X, I use launchd .plist files that have the OnDemand option set to True. I've … -
GSOC Status Update
This past week I worked up updating the model tests, and committed 7 changes. I did an analysis of the rate at which I need to finish the project, and I’m going to aim for converting 25 tests a week. I’ve gotten better at formulating unittests and have learned a bunch of useful emacs features. [...] -
Using Arecibo and Django, the easy way
So you've got your Django project on the production server. Want an easy way to track the errors in Django? The existing Django package is pretty easy to use, but it doesn't get much simpler than this: add in your Arecibo server to your ADMINS in settings.py. When Django emails out those error emails, it will send one to Arecibo. Arecibo will parse it and add it your site. The email address for that is: django-YOUR_PUBLIC_ARECIBO_KEY@yourserver.appspotmail.com. You can try this out right now, the email address for the test server is: django-sw3tqw35ywq45ws4kqa4ia6yw5q45serws23w351245lk6y@test-areciboapp.appspotmail.com Becomes: To do this we are parsing the email down, which is less accurate than just doing a HTTP post via the API, but its pretty easy to setup. Note: the key for the email address for the test server might change, you can find it on the setup pages on the test server. All errors are deleted after one hour on the test server. -
Review: Django 1.2 e-commerce
I already have Beginning Django E-Commerce. When Django 1.2 e-commerce came out, I thought, sure, why not. I’m a pushover for a good technical book. It has positive buzz, modulo some rumblings about glaring errors in the code samples. The quick details Chapter 1: What’s Django and why it’s good for e-commerce. Zzzzzzzz… Chapter 2: Quickly [...] -
PyFilesystem 0.3 released
I am pleased to announce a new version of PyFilesystem (0.3), which is a Python module that provides a common interface to many kinds of filesystem. Basically it provides a way of working with files and directories that is exactly the same, regardless of how and where the file information is stored. Even if you don't plan on working with anything other than the files and directories on your hard-drive, PyFilesystem can simplify your code and reduce the potential of error. PyFilesystem is a joint effort by myself and Ryan Kelly, who has created a number of new FS implementations such as Amazon S3 support and Secure FTP, and some pretty cool features such as FUSE support and Django storage integration. As an example of how awesome this package is, take a look at the following 6 lines of code, which creates a ramdrive: from fs.osfs import OSFS from fs.memoryfs import MemoryFS from fs.expose import fuse home_fs = OSFS('~/') home_fs.makedir('ramdrive', allow_recreate=True) fuse.mount(MemoryFS(), home_fs.getsyspath('ramdrive')) If you run this, a directory called ramdrive will appear in your home folder, the contents of which are stored purely in memory. I prepared a screencast that gives a quick demonstration of some features – because … -
PyFilesystem 0.3 released
I am pleased to announce a new version of PyFilesystem (0.3), which is a Python module that provides a common interface to many kinds of filesystem. Basically it provides a way of working with files and directories that is exactly the same, regardless of how and where the file information is stored. Even if you don't plan on working with anything other than the files and directories on your hard-drive, PyFilesystem can simplify your code and reduce the potential of error. PyFilesystem is a joint effort by myself and Ryan Kelly, who has created a number of new FS implementations such as Amazon S3 support and Secure FTP, and some pretty cool features such as FUSE support and Django storage integration. As an example of how awesome this package is, take a look at the following 6 lines of code, which creates a ramdrive: from fs.osfs import OSFS from fs.memoryfs import MemoryFS from fs.expose import fuse home_fs = OSFS('~/') home_fs.makedir('ramdrive', allow_recreate=True) fuse.mount(MemoryFS(), home_fs.getsyspath('ramdrive')) If you run this, a directory called ramdrive will appear in your home folder, the contents of which are stored purely in memory. I prepared a screencast that gives a quick demonstration of some features – because … -
PyFilesystem 0.3 released
I am pleased to announce a new version of PyFilesystem (0.3), which is a Python module that provides a common interface to many kinds of filesystem. Basically it provides a way of working with files and directories that is exactly the same, regardless of how and where the file information is stored. Even if you don't plan on working with anything other than the files and directories on your hard-drive, PyFilesystem can simplify your code and reduce the potential of error. PyFilesystem is a joint effort by myself and Ryan Kelly, who has created a number of new FS implementations such as Amazon S3 support and Secure FTP, and some pretty cool features such as FUSE support and Django storage integration. As an example of how awesome this package is, take a look at the following 6 lines of code, which creates a ramdrive: from fs.osfs import OSFS from fs.memoryfs import MemoryFS from fs.expose import fuse home_fs = OSFS('~/') home_fs.makedir('ramdrive', allow_recreate=True) fuse.mount(MemoryFS(), home_fs.getsyspath('ramdrive')) If you run this, a directory called ramdrive will appear in your home folder, the contents of which are stored purely in memory. I prepared a screencast that gives a quick demonstration of some features – because … -
Django-improved-inlines, enrichissez facilement vos contenus et ça, sans payer l’ISF
La pluie ayant décidé d'être l'invité surprise du week-end, j'ai donc une bonne excuse pour ne pas aller prendre des coups de soleil à la plage mais rester bien tranquillement sur mon clavier. Autant donc en profiter pour vous parler de l'application django du mois, j'ai nommé django-improved-inlines. Oui, je sais, elle a un ... -
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Aptana Studio and “Undefined variable from import: DoesNotExist”
Teaching Aptana Studio about DoesNotExist -
Falsehoods Programmers Believe About Names
Falsehoods Programmers Believe About Names. People’s names are complicated. I’m not at all comfortable with the commonly used first name / last name distinction (as baked in to Django auth) since it doesn’t take cultural factors in to account. -
Quick shell command to add CSRF token
To get the benefit of Django 1.2's new CSRF protection, all POST forms will need a special token. Here is a quick command that runs through templates adding the token: find . -type f -name "*.html" -exec sed -i \ 's|\(<form[^>]*method="post"[^>]*>\)\({% csrf_token %}\)\?|\1{% csrf_token %}|g' \ {} \; -
Using Fabric For Deployment
In a previous post I discussed what you want from an automatic deployment system. In this post I’ll discuss how use to solve the repeatability and scalability requirements that I set out. Fabric is a tool which lets you write scripts to automate repetitive tasks. So far, so bash like. What sets Fabric apart is [...]