Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#180 closed defect (fixed)

request.POST doesn't work in django_admin.py runserver

Reported by: edgars@… Owned by: Adrian Holovaty
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: no UI/UX: no

Description

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

Change History (14)

comment:1 by Jacob, 19 years ago

Resolution: worksforme
Status: newclosed

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

comment:2 by edgars@…, 19 years ago

Resolution: worksforme
Status: closedreopened

django.contrib.comment code does not work with django_admin.py 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/base.py", line 63, in get_response
    return callback(request, **param_dict)

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

Http404: Only POSTs are allowed

In django.contrib.comments.views.comment.py it checks whether request.POST is set, if not - raises this exception.

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

comment:3 by Clint Ecker <clintecker@…>, 19 years ago

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 by Adrian Holovaty, 19 years ago

Resolution: invalid
Status: reopenedclosed

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 by edgars@…, 19 years ago

Resolution: invalid
Status: closedreopened

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 http://www.dobbes.com/blog/2005/jul/23/django_comments/.

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 by clintecker@…, 19 years ago

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

comment:7 by Jacob, 19 years ago

Edgars: you're using the *exact* code from http://www.dobbes.com/blog/2005/jul/23/django_comments/ ? 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 by edgars, 19 years ago

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 object.id %}

<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>
</form>

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 by Philippe Normand, 19 years ago

I also followed the tutorial at dobbes.com. 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 by Philippe Normand, 19 years ago

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 by Adrian Holovaty, 19 years ago

milestone: Version 1.0

comment:12 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: reopenedclosed

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

comment:13 by Adrian Holovaty, 19 years ago

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 by (none), 18 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top