Wednesday, September 4, 2013

Connection Reset by Peer (104) on POST submission

I am trying to deploy my Django site. On my development environment using runserver, everything works perfectly. After deploying to production with Apache and Passenger WSGI on a shared hosting environment, the majority of the site works correctly. However, I am having one issue that I am unable to figure out.

When submitting a form via POST with enctype="multipart/form-data" and that has filefields or imagefields in the form, I get a connection reset page. The apache error log shows the following error:

[Wed Sept 4 17:11:53 2013] [error] [client 123.45.6.78]
(104)Connection reset by peer: ap_content_length_filter: apr_bucket_read() failed, referer: http://www.example.com

Has anyone experienced this error or know how to fix it?

Below is the form file, template and view code that handles the POST submission:

<-------- forms.py ---------->
class TestForm(forms.Form):
    name = forms.CharField(label='Last Name', max_length=100)
    file = forms.ImageField(required=False)
<-------- end forms.py ---------->

<-------- test_page.html ---------->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
{% if form %}
    <form action="" method="POST" enctype="multipart/form-data">
        {% for field in form %}
        <div class="fieldWrapper">
            {{ field.errors }}
            {{ field.label_tag }}: {{ field }}
        </div>
        {% endfor %}
        {% csrf_token %}
        <input id="submit" type="submit" name="submit" value="Send" />
    </form>
{% endif %}
</body>
</html>
<------- end test_page.html ------->

<-------- views.py ------------->
from django.template import RequestContext
from forms import TestForm

def test_form_view(request):

if request.method == 'POST':

return render_to_response('test_page.html',{},)

else:
return render_to_response('test_page.html',{ 'form': TestForm(), },
context_instance=RequestContext(request))
<------------ end views.py ------------>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate