Djangetting it!

I’m slowly getting my head around Django, and the more I do, the more I appreciate what it’s doing.

The Models part of it I found pretty easy, it’s just defining fields in a database and any additional parameters, and writing templates has been pretty good too, but tying views.py to urls.py (basically telling the website what data to load when a certain URL is requested) has had my head in a mess.

The fact that regular expressions feature in the URLConfs (urls.py) doesn’t help. If you’ve never had the pleasure of working with regexs, have a look at the following, which is actually a very simple one to load a record by its ID number for displaying on the webpage:

url(r'^(?P<pk>\d+)/$'

Yeah, fun…

So not only have I been trying to get my head around learning Django and regexs, I’ve been trying to make it actually do what I want it to. One of the hardest things I found was trying to get my urls.py to pass variables to views.py in order to have them rendered in a template. Now that I’ve actually figured that out, it’s like opening a flood-gate, all of a sudden I seem to just be understanding everything better.

Obviously I’ve now jinxed that, and am about to hit another brick wall, but at least I know I can get past those walls, even if it means picking the mortar apart and taking it down brick-by-brick.

Leave a Reply