Today's Django tip

Posted by andu
Mon, 2006-02-13 10:08

Don't use the post url in a form like "/contact" because you will lose the post data. The correct way is "/contact/".

The reason this doesn't work is that when passed "/contact" you get a redirection to "/contact/", and all the post data is lost. For get, it works though.

Trackback URL for this post:

http://www.voidberg.org/trackback/69

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Romerican (not verified) - Wed, 2006-10-04 20:09

From Django
---------------

AnJrew May 27, 2006 at 11:55 p.m.

Can anyone explain to me why it is not possible to use a url in the form 'http://example.com/path/ending/in/word' (with no trailing slash), unless that final word contains a period? I can get it to work with 'page.html' and even 'page.' or '.page' but as soon as I remove the dot, the web server sends the browser a redirect appending a slash without giving it to the URL dispatcher.

I don't know whether this is just the behaviour of the built-in development server, or something more generic that all web servers are supposed to do - it might make some sense when serving pages from a filesystem, but doesn't for an application with a URL dispatcher like django. Anybody?

Simon Willison May 28, 2006 at 5:30 a.m.

AnJrew: that's a feature of the common middleware, which is on by default. You can turn it off by setting APPEND_SLASH = False in your settings.py.

andu - Thu, 2006-10-05 13:03

Good to know, thanks.

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.