Entries published on November 6, 2007
URLConf tips and tricks
I’ve written a couple of things recently talking about useful things to be aware of when you’re putting together the URL configuration for a Django application — one covering a pitfall you should watch out for with regular expressions and one touching on the utility of the “url” tag and the “permalink” decorator, and the “reverse” utility — but you can never have too much useful information about URL configuration, because for a lot of people it seems to be one of the trickier parts of Django. So let’s look at a few more things you might not know about.
Be careful with module globals
Fairly regularly, someone pops up complaining that a value seems to be magically “cached” somehow, because a variable whose value is supposed to change over time isn’t changing at all. For example, someone might have a URLConf like this:
from django.conf.urls.defaults import * from blog.models import Entry, …