Tutorial 4: Writing first Django App (Part 3)

Tutorial used: https://docs.djangoproject.com/en/dev/intro/tutorial03/

What I Learnt:

Concept 1: URLconf files map URL patterns to Python callback fn views
Screen Shot 2013-01-04 at 11.28.16 PM

Concept 2: urls.py (mysite) > urls.py (polls) > views.py
Screen Shot 2013-01-04 at 11.29.10 PMScreen Shot 2013-01-04 at 11.29.17 PMScreen Shot 2013-01-04 at 11.29.26 PM Screen Shot 2013-01-04 at 11.29.32 PM   
Screen Shot 2013-01-04 at 11.29.42 PM

Concept 3: Regular Expression is important for urlpatterns
Wiki Documentation of RegEx
Python Re Documentation

Concept 4: Views are to Return HttpResponse or raise an Exception
Screen Shot 2013-01-05 at 12.10.22 AM

Concept 5: Render a Template with a Context
Rendering and Context is created in “mysite/polls/views.py”
Template is stored in “mysite/mytemplates/polls/index.html”
Screen Shot 2013-01-05 at 12.29.08 AM

Concept 6: a shortcut to do Rendering – Render()
Screen Shot 2013-01-05 at 12.31.55 AMConcept 7: Namespacing URL names allow django to differentiate URL names when {% url %} is used

Screen Shot 2013-01-05 at 5.10.45 PM


NoReverseMatch at /polls/

u’ “polls’ is not a registered namespace

apparently django does not recognize the namespace u’ “polls ‘. We have named the namespace in the project url file. But the reason why django does not recognize it is because of the quotation marks. Remove the quotations marks to solve the problem.

DEBUGGED: ‘polls:detail’  > polls:detail

This entry was posted in Tutorials. Bookmark the permalink.

2 Responses to Tutorial 4: Writing first Django App (Part 3)

  1. Brendan says:

    Thank you so much for the namespace fix.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s