At the url /sites/1 I have a form:
<form action="." method="post">
...
However when I submit it, it is handled at /sites/ by a different view, causing an error.
Here is my urls.py:
url(r'^sites/$', 'app.views.sites_view'),
url(r'^sites/(?P<site_id>\d+)$', 'app.views.site_view'),
...
What’s going wrong?
Your URLs are not consistent in their use of trailing slashes.
The browser treats URLs as a directory structure.
.means the root of the current “directory”. If you’re at/sites/1, then the “current directory” is/sites/. If you were at/sites/1/– ie with a trailing slash, as recommended in the Django docs – then the current directory will still be/sites/1/.Ensure all your URLs end with slashes, and use the default append slash functionality to redirect to the slash-appended version of any URL.