Tango with Django Chapter 7 (Add_page)

633 views
Skip to first unread message

Amimo Benja

unread,
Nov 13, 2013, 7:14:40 AM11/13/13
to django...@googlegroups.com
Hey all,

Am currently practicing using this tutorial http://www.tangowithdjango.com/book/chapters/forms.html, but I'm constantly getting this error "The current URL, rango/category//add_page/, didn't match any of these." every time I click on the Add a Page link in the Category.html. I don't know how to solve it. Any help? Thanks.

Here are my 

Sergiy Khohlov

unread,
Nov 13, 2013, 7:38:47 AM11/13/13
to django-users
try to change
<a href="/rango/category/{{ category_name_url }}/add_page/">Add a Page</a>
to
<a href="url {% 'views:category_name_url' %}/add_page/">Add a Page</a>
Many thanks,

Serge


+380 636150445
skype: skhohlov
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4731ffd8-f500-40a2-af7b-9587195bc092%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Amimo Benja

unread,
Nov 14, 2013, 7:07:45 AM11/14/13
to django...@googlegroups.com
It seems not to be working. It raises an error that Invalid block tag: ''views:category_name_url''

Lee

unread,
Nov 14, 2013, 7:08:27 AM11/14/13
to django...@googlegroups.com
Noob here so I may be way wrong but it looks to me like your problem is probably in link in category page when generating the link to add_page, given the url in the error is missing the category name in the URL. Have you passed category_name_url from your view function to the category template? Your views.py link seems to show forms.py rather than the view functions so I cant see the view, but my category view looks as follows and works:

 def category(request, category_name_url):
context = RequestContext(request)
category_name = decode_url(category_name_url)
context_dict = {'category_name': category_name, 'category_name_url': category_name_url}

try:
category = Category.objects.get(name=category_name)
pages = Page.objects.filter(category=category)
context_dict['pages'] = pages
context_dict['category'] = category
except Category.DoesNotExist:
pass

return render_to_response('rango/category.html', context_dict, context)

And I am also mid way through Tango with Django if you hadn't guessed ;-)

Amimo Benja

unread,
Nov 14, 2013, 7:16:06 AM11/14/13
to django...@googlegroups.com
Thanks Lee, it worked. The problem was I had not passed category_name_url from my view function to the category template. The moment I passed it, it worked without any problem. Thanks a lot Man. At least I can proceed. Phee...w!!! Thanks again.

Lee

unread,
Nov 14, 2013, 8:49:13 AM11/14/13
to django...@googlegroups.com
No problem at all, glad it worked out for you :-)

Good luck with the rest of the tutorial

Cheers

Amimo Benja

unread,
Nov 20, 2013, 9:12:19 AM11/20/13
to django...@googlegroups.com
Hi Lee,

I have been continuing with the django tutorials and at the moment I am on chapter 10 dealing with cookies.

On the exercises when a user logs in and clicks the about page link, mine just shows he visited the site 1 time no matter how many times he clicks on the about page. Is it supposed to be so or am I missing something? 
Reply all
Reply to author
Forward
0 new messages