I can't catch a URL in Django

8 views
Skip to first unread message

אורי

unread,
May 6, 2020, 7:17:07 AM5/6/20
to django...@googlegroups.com
Hi,

I'm trying to convert my website from using re_path to path. I have a URL https://en.speedy.net/about/  , and if the user types any URL which starts with /about/, such as https://en.speedy.net/about/1/ - he is redirected to https://en.speedy.net/about/ .

In urls.py I have:

re_path(route=r'^about/', view=include('speedy.core.about.urls', namespace='about')),  

And in about/urls.py:
re_path(route=r'', view=views.AboutView.as_view(), name='about'),

The view handles the redirect if necessary.

Now, I changed urls.py to:
path(route='about/', view=include('speedy.core.about.urls', namespace='about')),
And about/urls.py to:
path(route='<path:rest>', view=views.AboutView.as_view(), name='about'),
But, if the user enters /about/1/, he is redirected to /about/, but then I receive error 404. What is the problem and how should I define it? I prefer not to have to use <path:rest> but catch any url which starts with /about/ .

Thanks,
Uri.
אורי
Reply all
Reply to author
Forward
0 new messages