Django not adding / to end of URLS and since urls.py expects /, I now get 404s. How fix?

42 views
Skip to first unread message

Chris Seberino

unread,
Apr 23, 2016, 2:50:05 PM4/23/16
to Django users
I am trying to be consistent and make urls.py expect / after every url.

The problem is Django isn't automatically adding / at the end and so now
I get 404s when I try to access my web pages.  

How fix?

Thanks!

Chris

Michal Petrucha

unread,
Apr 23, 2016, 3:03:55 PM4/23/16
to django...@googlegroups.com
https://docs.djangoproject.com/en/1.9/ref/settings/#append-slash

But this shouldn't happen to you with URLs from within your
application, as long as you use the url template tag, and reverse for
redirects – those will generate correct URLs for you, including the
trailing slash, as long as it appears in the URL regex.

Cheers,

Michal
signature.asc
Reply all
Reply to author
Forward
0 new messages