Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP 403 with django form submission only on IE9
    primarykey
    data
    text
    <p>I'm working on Django version 1.4.2. I've implemented this simple form example (inspired from djangobook) :</p> <pre><code># views.py from django.shortcuts import render from django.http import HttpResponseRedirect from django.core.mail import send_mail from mysite.contact.forms import ContactForm def contact(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): cd = form.cleaned_data send_mail( cd['subject'], cd['message'], cd.get('email', 'noreply@example.com'), ['siteowner@example.com'], ) return HttpResponseRedirect('/contact/thanks/') else: form = ContactForm() return render(request, 'contact_form.html', {'form': form}) # contact_form.html &lt;html&gt; &lt;head&gt; &lt;title&gt;Contact us&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Contact us&lt;/h1&gt; {% if form.errors %} &lt;p style="color: red;"&gt; Please correct the error{{ form.errors|pluralize }} below. &lt;/p&gt; {% endif %} &lt;form action="" method="post"&gt; &lt;table&gt; {{ form.as_table }} {% csrf_token %} &lt;/table&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; # forms.py from django import forms class ContactForm(forms.Form): subject = forms.CharField() email = forms.EmailField(required=False) message = forms.CharField() </code></pre> <p>Everything just work fine for all browsers i've tried (chrome, maxthon, firefox) but in IE9, i get a HTTP 403 refused.</p> <p>Any clue about what's causing that ?</p> <p>EDIT : after deeper investigations, I found that the problem comes from this : when asking the empty form, the navigator receives the csrf cookie, but for an unknown reason, it doesn't send back this cookie when posting the form. This problem seems to arise only when the cookie comes from the nginx server at pythonanywhere.com , when I test from an apache server of my own, cookie is sent back ok.</p> <p>Here are the two headers captured from servers :</p> <pre><code>HTTP/1.1 200 OK Server: nginx/1.2.5 Date: Wed, 21 Nov 2012 13:56:31 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Cookie Set-Cookie: csrftoken=1AJjzkbUgJdKAmkbiHicJ3or2Mfi6AbD; expires=Wed, 20-Nov-2013 13:56:31 GMT; Max-Age=31449600; Path=/ HTTP/1.1 200 OK Date: Wed, 21 Nov 2012 13:56:50 GMT Server: Apache/2.2.15 (CentOS) Vary: Cookie Set-Cookie: csrftoken=2iMZSH1s0vJnEt4tRRY7FciT1Q7orrVF; expires=Wed, 20-Nov-2013 13:56:50 GMT; Max-Age=31449600; Path=/ Keep-Alive: timeout=180, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 </code></pre> <p>The only significant difference seems to be the Kee-Alive header from apache...</p> <p>Do you think it can comes from there ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload