Opened 16 years ago
Closed 16 years ago
#10441 closed (invalid)
form action="."
Reported by: | rihad | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Chapter 7 of The Django Book says this:
The action="." means “Submit the form to the same URL as the current
page.”
I'm not sure this is standard or not, but it doesn't do what's
expected at least on Firefox 3.0.6 (Iceweasel of Debian 5.0 stable):
the form is simply submitted to an emtpy URL "/", which Django's web-
server logs on the console:
[08/Mar/2009 14:26:07] "GET /search HTTP/1.1" 200 205
[08/Mar/2009 14:26:10] "GET /?q= HTTP/1.1" 200 17
i.e. the first line shows me opening the form, and the next one logs
form submission, i.e. no HTTP-level redirects are ever done.
my urlpatterns looks like this:
...
(r'search/*$', search),
...
that is, the trailing slash is optional. Very interestingly, the "."
action submits correctly to itself only if I open the form as "http://
example.com/search/", not as "http://example.com/search" in the first
place, as the Django Book recommends. So it would be more correct to
say that "action="." submits the form to the same URL up to and
including the trailing slash, ignoring everything after it".
As explained in the thread on django-dev, this is working correctly. It requires understanding how relative URL references work (without the trailing slash, the last component will be stripped). All the Django documentation uses trailing slashes on URLs, partly because it provides the ability to use this kind of relative URL reference.
If there's a problem in the documentation for Django itself (at docs.djangoproject.com), then that would be good ot know about and fix. However, if this is just a problem with the book and djangobook.com, errors should be reported over there. That is separate from Django itself.