views:

399

answers:

1

I have copied the simple Django forms example exactly, running on localhost. The basic contact form example should submit a POST request when you click the Submit button.

I'm running Chrome on Mac Snow Leopard, and whenever I submit the form, the page simply reloads with an empty form: I can see from the runserver output that it's not sending a POST - instead it's sending a GET request.

If I open the same page in Firefox on Mac Snow Leopard, and submit the form, I can see it's sending a POST request (as it should be).

Looking at the source in Chrome, the form definitely says method="post".

<form action="/contact/" method="post"> 
<p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" /></p> 
<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p> 
<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" /></p> 
<p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p> 
<input type="submit" value="Submit" /> 
</form> 

External sites with POST forms seem to work OK in Chrome.

In addition, if I fill the form in incorrectly, in Chrome the page just reloads, with a GET request, as before; in Firefox the form gets validated, as it should.

I've tried with other POST forms on localhost and got the same result.

I know Chrome for Mac has its quirks, but what on earth is going on?

A: 

This is likely being caused by Chrome treating each file:// URL as a different domain. Try launching Chrome with the --allow-file-access-from-files option and see if that helps.

Update: You'll have to close all existing Chrome instances and launch a fresh instance with that option to notice any difference.

jamessan
Thanks. Could be, although: (i) I have the problem on forms that don't involve file uploads, and (ii) forms have always previously worked fine on locahost in Chrome, this seems to be a new thing. I'm just trying to work out how to launch Chrome from the command line in Mac OS...... sigh
AP257
My comment had nothing to do with file uploads. If you're accessing the web page from a `file://` URI instead of via an `http://` URI, then every file is considered its own domain. The reason you wouldn't have seen this before is that this behavior was only enabled on Feb. 24th's dev channel update.
jamessan
Oh I see. No, I was using http://localhost:8080. The behaviour has gone away now. Bizarre! Thanks anyway.
AP257