RECAP

So you already know urls are routed through the different urls.py files to the functions defined in views.py. The functions take an http request and return and http response. The rest is up to you. Now let’s do some damn routing.

Make some view functions that take More Than One argument, eg:

def detail(request, question_id):
	return HttpResponse("You're looking at question %s." % question_id)

then do the routing: (Now with wildcards for variable assignment!!! So cool!!!)

url(r^'detail/(?P<question_id>[0-9]+)/$', views.detail, name='detail'),

Basically urls.py is defining the API that you’re allowing the outside world to use. In fact that’s exactly what it’s doing. Very cool. So you have to be careful in how you define it. It should be whitelisty not blacklisty.

Now make your shit active.

(gonna get more sparse from here. I’m not here to write a tut.)

Templates

mkdir /polls/templates - it has to be called “templates” if you want default detection to work.

Don’t forget to namespace your urls

…if you have multiple apps and are using url templates in your view links. Which you maybe shoul be cos it’s pretty cool.

Bam. Done.