Templates, Tags, & Tricks
Django URL Structure
Utterly Unblemished URL's
Django structures your website URL's in an
interesting way
Recap: the URL is the text you type to get to a
website
For nonDjango websites:
http://www.example.com/some/directory/index.php
Refers to a file /some/directory/index.php on the
server
Different in Django! URL's are organized more
elegantly and more easily understandably
Utterly Unblemished URL's
Consider this example:
http://example.com/articles/2005/03/
URL specifies article date, not a reference to a
specific file
Allows a more logical organization, that is less
likely to change over time
Utterly Unblemished URL's
Overview of how Django works, using URL's
http://example.com/articles/2009/01/27
URLConf
View: polls()
View: articles()
View: authors()
Template: fancy
URLs
Views
Templates
Template: cute
Template: plain
Utterly Unblemished URL's
URL patterns map to Views
Views may use templates
Templates contain HTML (discussed later)
This puts a layer of abstraction between URL
names and files
The file
urls.py
that specifies how URL's get
mapped to views, using regular expressions
|