Version 62 (modified by Collin Grady, 11 years ago) (diff)


This is a work in progress, answering questions that do indeed get asked frequently on the Django IRC channel (#django on Feel free to contribute, but try to keep it clear and concise. Please don't editorialize.

There's also a helpful official FAQ.


General Tips

  • When asking for help in the channel, be as specific as possible in your request. "It doesn't work" is not sufficiently specific!
  • Standard problem-reporting advice: Describe 1) what you did, 2) what you expected to happen, and 3) what actually happened.
  • General problem-solving advice: Test all the things you think are true until you find the one that isn't.
  • Showing actual code is useful. For code longer than a line or two, use the pastebin:
  • Django has very good documentation. Make sure you've checked it!
  • Try searching in Trac.
  • Don't ask to ask, just ask!

Python questions

How do I learn Python if I'm new to programming?

How do I learn Python if I'm not new to programming?

Are there any books on Python?


Django questions

Which version should I use, the 0.96 release or the Subversion checkout?

The 0.96 release is well-tested and stable, and is best for production deployments. Tracking the development version of Django through a Subversion checkout can be nice if there's a new feature you really want, but does require you to pay more attention to what's going on in Django development -- if a backwards-incompatible change is introduced, you'll need to be watching the development timeline to notice it and change your code to suit, where sticking to official releases means that you get a list of any changes you need to make in the release notes.

All backwards incompatible changes are (or should be) also recorded on the BackwardsIncompatibleChanges wiki page. Let us know (file a ticket) if you notice any genuine backwards incompatibilities that are missing.

There will be several backwards-incompatible changes before the next release of Django (for example, the workings of the admin app will be changing), so it's officially recommended that production deployments stick to the 0.96 release until the next release is ready.

I'm using the development version (via Subversion) and when I ran "svn up" a bunch of stuff broke!

Don't use the development version of Django unless you also follow the BackwardsIncompatibleChanges and possibly the timeline as well. That way you can see what has changed *before* you update.

That way, changes like auto-escaping of HTML in templates won't catch you by surprise.

Also, when reading the documentation, keep a special eye out for the "New In Development Version" sections.

Should I read the documentation on the website, or

Start with the documentation here, and then have a look at the book if you're interested; the documentation on includes the official tutorial, and a number of comprehensive references which aren't currently available in the book.

How do I extend a model? I want to subclass django.contrib.auth.models.User.

This feature has been added to the queryset-refactoring branch, but it is not available in either the trunk or a numbered release yet. Specific instructions for the User model can be found at and

If I change my model, will syncdb update my database table?

No, you'll need to manually change your database table. If you use sqlall on your app to produce a SQL file before editing your models, you can run it again afterwards and use the difference between the two to see what you need to change in the database.

What should I use for development -- the built-in server, mod_python, FastCGI?

It's generally easiest to use the built-in development server, since it automatically reloads your Python source files when it detects changes. (Some prefer to replicate the production environment as closely as possible, meaning that if their deployed project uses mod_python then their development server does as well.)

What's the difference between null=True and blank=True in models?

null=True means that the database will accept a NULL value for that field; blank=True means that Django's validation system won't complain about a missing value. If you use blank=True but not null=True you will need to have your code fill in a value before storage in the database -- specifying a default on a field, or putting something in the model's save method to generate a value are two good ways to handle this, and can be extremely useful when you want to calculate one field's value based on others.

I think Ajax is awesome! How do I do Ajax with Django?

Choose your favorite excellent Javascript library and go to it. Django provides serializers to JSON and XML, which you can read about in the documentation:

Also see this helpful article from James Bennett (with bonus anti-Javascript-helpers rant!):

Is there a free CMS available for Django?

At this point there is nothing well-established (like Plone, for instance). In practice, people mean so many different things by "CMS" that it may be hard to get a straight answer. This question is often asked by newcomers; one recommendation is to learn a bit of Django and see just how easy it is to make a site that does what you want. If you're in a big rush, there's always Ellington:

What database should I use?

For development, most people find SQLite to be fastest and simplest to run with -- just make sure the database file and its directory are writeable by the owner of the web server process. For production, PostgreSQL and MySQL are the most thoroughly-tested of the databases Django supports, but it's best to choose based on the needs of your applications; for example, applications which do very little writing of data to the DB will enjoy the speed of SQLite, but applications which involve many complex queries or which require robust concurrent-write features like transaction isolation will probably want to look at Postgres or MySQL (and, of course, MySQL is often handy simply because many shared hosting providers have it set up by default).

The admin is working, but it can't find the Javascript and CSS and image files.

If you're running the development server, read this:

If you're running Apache, read this:

Do I have to hard-code my media URL in all my templates for CSS, images and Javascript?

No; you can use {{ MEDIA_URL }}. If you're using the development version of django and generic views, you can use {{ MEDIA_URL }} without changing anything.

If you're using the development version and render_to_response(), you'll have to include RequestContext, as described here:

If you're using 0.96, you can get the same functionality by creating a template context processor, as described:

I'm trying to install Django on Windows and something is weird.

Have you looked here?

What editor is best for Django?

Vim. No, wait, Emacs. A lot of people seem to like TextMate, too.

The best editor is the editor you prefer.

How do I customise the admin interface so all logged-in users can use it without screwing up anything?

The admin interface is designed for use by trusted site staff, not by any user -- if you don't trust a user with the level of access the admin application provides, you'll need to provide non-admin views for the actions you'd like to allow them to take.

How do I make extensive changes in the admin interface?

At the moment it's probably best not to; the admin app is fairly specialized and doesn't have a lot of places to customize behavior, so you'll usually end up writing less code by just rolling your own set of views. The newforms-admin branch, however, will significantly refactor the admin app to make customization much simpler.

I have created several users, but only the superuser is able to log into the admin

In .95 and prior releases, you cannot put a plain password when creating a new user in admin -- the form expects a hashed password in the format which will be stored in the database. In Django 0.96 and later, this is not a problem.

Also, keep in mind that admin access requires the "is_active" and "is_staff" boxes to be checked for the user.

When will the next release be out? -or- When will X branch be done?

"When it's done" is the short answer. Fixed release dates are rarely set, but searching or browsing the developer list ( can be informative.

If you always want to run with the bleeding-edge, just use the SVN trunk rather than the last release (it's kept stable and is updated nearly every day).

I want to repeat a bit of dynamic information (eg from a database) on many views. Do I have to change every view?

No, you can use an inclusion tag.

Why isn't my template tag or filter working?

Of course, you've read the documentation, right? Here's a brief list of things to check first before asking:

  • your filter/tag should be in a file named something like [yourfilterlibraryname].py (e.g. if it was, you'll use {% load myfilter %} in the template)
  • that file exists in a directory named templatetags and this directory is sitting inside of an app directory (e.g. .../projectdir/appdir/templatetags)
  • an empty file named also exists in the templatetags directory (this makes the directory into a python module which can be imported)
  • in your project, the application where the templatetags directory is contained is in INSTALLED_APPS
  • each filter or tag in your library is decorated correctly (see docs)
  • neither your library nor anything it imports raises any exceptions (for example, if your library tries to import something that's not installed, and so raises an ImportError, that will prevent Django from seeing it)
  • restart the webserver (yes, even if you're using runserver)

I'm using Ubuntu Feisty Fawn and I get an error while using the tutorial

Feisty Fawn ships with Python 2.5.1-c1. Just run apt-get update and apt-get install python2.5 should fix those problems.

I want to have some code run when the server/application starts. How do I do that?

Both mod_python and FastCGI are structured in such a way that there's no such thing as "application startup" or "server startup"; the best solution is to place your "startup" code somewhere that's guaranteed to be imported early on in the request/response cycle (the file of your project, or of a specific application you're using, can be a good place, because Python will execute code found there the first time it has to import the module; just be aware that referencing the same module in different ways, say by doing from myproject.myapp import foo in one place, and from myapp import foo in another, will cause that code to be executed once for each different way you import it).

I have a DateField or DateTimeField with a default value of now(), but it's not working!

What you've probably done is something like this:

some_date_field = models.DateTimeField(

When you do that you're immediately calling and passing its return value -- at the moment the class is defined -- to be the default, which means it will not change during the life of a server process. What you want to do instead is this:

some_date_field = models.DateTimeField(

Note that there are no parentheses on in this version, so you're passing the function itself to be the default. When Django receives a function as a default value for a model field, it will call the function each time a new object is saved, and that will correctly generate the current date/time for each object.

I'm trying to use __str__() or __unicode__() on my model, but it's not working

It's likely that you're using __str__() with the development version of Django, or __unicode__() with a release version. After the release of 0.96, Django's internals became fully Unicode aware. As a result, model classes that used to use __str__() to provide string versions of themselves need to be updated to use __unicode__() to work with the development version of Django. However, users of a Django release still need to use __str__().

More information on exactly what changed regarding Unicode in Django is available on the UnicodeBranch page.

How do I use Django in a shell script?

Can I use the Date/Time picker JavaScript from the Admin in my own app?

Short answer: No.

Long answer: It is possible, but requires reusing the Admin JS and CSS, and is more trouble than it is worth. Most JavaScript frameworks (such as YUI, Dojo, jQuery, and Prototype) provide similar functionality, either out of the box or through plugins. Additionally, there are many JavaScript snippets available across the Web.

The ticket tracker thinks I'm a spammer!

You need to register:

Is there a channel bot?

Yes, it's very handy -- see DjangoBot for more.

python gives cannot find bdb.settings, but I can import bdb from the python prompt

You have named your project 'bdb' which is the name of an existing python module. Do not name your project after and existing python module

Where do I find/post interesting snippets?

Where do I find a list of good django sites with source - look for 'sites with source'

Back to Top