Getting a PageNotFound 404 Error

13 views
Skip to first unread message

Александр Мусаров

unread,
Jul 29, 2015, 12:53:00 PM7/29/15
to Django users
Hi, folks! I'm new to Django, now I'm writing my first e-commerce in it, and now I'm having a mistake that I can not find in code myself. Please help me..

The code is the following:

The trouble URL code line :   url(r'^(?P<category_slug>[-/w]+)/$', views.category, name = 'category_detail'),

The view code : def category(request, category_slug):
                           c = get_object_or_404(Category, category_slug = category_slug)
                           products = c.product_set.all()
                           page_title = c.category_name
                           meta_keywords = c.category_meta_keywords
                           meta_description = c.category_meta_description
                           return render(request, 'categories/category.html', locals())

Thanks for your help in advance..

James Schneider

unread,
Jul 29, 2015, 12:56:46 PM7/29/15
to django...@googlegroups.com

Instead of /w you should use \w in your URL regex, right now all you are matching is literally  - and / and w...

-James

--
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/3866fec2-4497-48c9-9f83-86f98c0143cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Александр Мусаров

unread,
Jul 29, 2015, 1:16:08 PM7/29/15
to Django users, jrschn...@gmail.com
Thanks a lot!!! Damned regexes...

среда, 29 июля 2015 г., 19:56:46 UTC+3 пользователь James Schneider написал:
Reply all
Reply to author
Forward
0 new messages