Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#180 closed defect (fixed)

request.POST doesn't work in runserver

Reported by: edgars@… Owned by: adrian
Component: Tools Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Maybe you should warn people that only tutorial code works with it ;)

Attachments (0)

Change History (14)

comment:1 Changed 9 years ago by jacob

  • Resolution set to worksforme
  • Status changed from new to closed

request.POST works just fine for me; if there's something more complicated wrong please feel free to reopen this ticket.

comment:2 Changed 9 years ago by edgars@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened

django.contrib.comment code does not work with runserver.
This is the error message after doing a preview comment POST:

There's been an error:

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/django/core/handlers/", line 63, in get_response
    return callback(request, **param_dict)

  File "/usr/lib/python2.4/site-packages/django/contrib/comments/views/", line 279, in post_free_comment
    raise Http404, "Only POSTs are allowed"

Http404: Only POSTs are allowed

In it checks whether request.POST is set, if not - raises this exception.

if not request.POST:
        raise Http404, "Only POSTs are allowed"

comment:3 Changed 9 years ago by Clint Ecker <clintecker@…>

Correct me if I'm wrong, but POST stuff is simply not going to work with the built-in server. I don't think it's that robust.

comment:4 Changed 9 years ago by adrian

  • Resolution set to invalid
  • Status changed from reopened to closed

POST does indeed work perfectly with the built-in server. For proof, just edit an object in the admin.

The problem in this specific case is that you're not using the comments framework correctly. That's not surprising, because it's not documented yet. But this has nothing to do with POST not working in the core framework. It works perfectly.

comment:5 Changed 9 years ago by edgars@…

  • Resolution invalid deleted
  • Status changed from closed to reopened

I don't want to keep bugging you, but the same comment code works perfectly when using mod_python.
So I doubt that incorrect usage is the problem. I use the comments as documented in

If that indeed is incorrect usage (which somehow works with modpython) then don't hesitate to resolve it.

Thank you for your patience.

comment:6 Changed 9 years ago by clintecker@…

Sorry, I was thinking about FileFields, not POST. Obviously POST works ;)

comment:7 Changed 9 years ago by jacob

Edgars: you're using the *exact* code from ? Because I've just verified that this works on both my Linux box and my Mac; can you tell me in excruciating detail what your setup is, and maybe attach your code? Otherwise I doubt we're going to able to fix this one since it works perfectly for us.

comment:8 Changed 9 years ago by edgars

jacob: The box is Ubuntu Hoary, python 2.4.1. The form is generated by django.contrib.comments tag - {% free_comment_form for blog.entries %}

<form enctype="multipart/form-data" action="/comments/postfree/" method="post">
<p>Your name: <input type="text" id="id_person_name" name="person_name" /></p>
<p>Comment:<br /><textarea name="comment" id="id_comment" rows="10" cols="60"></textarea></p>

<input type="hidden" name="options" value="ip" />
<input type="hidden" name="target" value="12:4" />
<input type="hidden" name="gonzo" value="dc82e793270264b4e30fecf86a8db36b" />
<p><input type="submit" name="preview" value="Preview comment" /></p>

Submitting it results in the traceback posted earlier. There was one person at the irc channel today who also had the same problem, so it's not only me.

comment:9 Changed 9 years ago by Philippe Normand

I also followed the tutorial at And i got the same problem as Edgar. I also tried the same code under mod_python and it worked in one shot.

comment:10 Changed 9 years ago by Philippe Normand

Additional informations follow. I'm using Debian Sid, Python 2.3.5, Django rev #321, apache2 2.0.54-4, mod_python 3.1.3-3

comment:11 Changed 9 years ago by adrian

  • milestone set to Version 1.0

comment:12 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [377]) Fixed #180 -- Removed 'enctype' from FREE_COMMENT_FORM template in contrib.comments.templatetags

comment:13 Changed 9 years ago by adrian

This is fixed now. It wasn't a request.POST issue -- it was an issue with the freecomments form, which was using enctype="multipart/form-data" by mistake.

comment:14 Changed 7 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.