Wednesday, July 29, 2015

Re: Getting a PageNotFound 404 Error

Thanks a lot!!! Damned regexes...

среда, 29 июля 2015 г., 19:56:46 UTC+3 пользователь James Schneider написал:

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

-James

On Jul 29, 2015 9:52 AM, "Александр Мусаров" <alex...@gmail.com> wrote:
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..

--
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.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/aed27f33-b955-4d32-a381-eaa65503de31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment