On 3/9/06, Glenn Tenney <[EMAIL PROTECTED]> wrote:
I've taken a working template and a working detail view and added
a form to that template AND another view to handle that form when
submit gets clicked.
In my template I've got:
<form action="" method="post">
Rating: <input type="text" id="rating" class="vIntegerField required" name="rating" size="3" value\
="" />
<input type="submit" value="Rate this show" />
</form>
and that view's code is:
def place_rated(request, app_label, module_name, object_id=None, template_name=None):
foo = foobar
try:
s = places.get_object(id__exact=object_id, select_related=True)
except:
raise Http404
# we either have a rating already or have to create one
rating = 0
if request.POST:
foo = foo
# this will actually do some other stuff, but... for example...
s.rating = request.POST['rating']
s.save()
foo = bar
return HttpResponseRedirect("/place/%s/" % object_id)
When I clicked on the form it got to that view just fine, but never seemed to do
anything, so... I added the "foo=..." lines purposely for debugging to throw an exception
to see what was happening.
I added the "foo = foobar" line because it never got to the "foo = foo" line
(i.e. never got to the "if request.POST").
it barfs on the foo = bar line and the debug info shows:
Request Method: GET
...
GET No GET data
POST No POST data
I thought that clicking on the SUBMIT button would be a post method
and that request.POST would be true (and POST would be
populated)... but it's not. Because it gets an exception at the
"foo=..." line, I know that it is getting to that view when I click
submit.
Huh? ????????? What's happening? What am I doing wrong? ?????
p.s. although it never gets to the line "... request.POST['rating']",
is that the right way to write it to pull the input field named "rating"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---