Re: why is my view for a submitted form not getting a POST?
Amit Upadhyay wrote: > . is django way of handling form is there is any, makes it more > "portable", one less thing to change when you are relocating your > pages on your site, and your template need not know the actual page > where the form would be deployed. In fact tutorial could easily use action="./" to avoid confusion. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: why is my view for a submitted form not getting a POST?
On 3/9/06, Glenn Tenney <[EMAIL PROTECTED]> wrote: see http://www.djangoproject.com/documentation/forms/ in the finishedversion of the "create_form" template it uses "action="" with no trailing slash.A . means the current page, and given the page was generated by django, which always adds a / to all page URLs its gauranteed that current page will end with a /. . is django way of handling form is there is any, makes it more "portable", one less thing to change when you are relocating your pages on your site, and your template need not know the actual page where the form would be deployed. Django facilitates these things as best practices, you are completely free to follow whatever your requirements tell you. Its usually recommended to serve the form in the GET request and handle it in POST request on the same url. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: why is my view for a submitted form not getting a POST?
On Thu, Mar 09, 2006 at 11:21:38PM +0800, limodou wrote: > Please check this document http://code.djangoproject.com/wiki/NewbieMistakes > It seems that you lost a '/' after action name "rated". Whoa! Thanks!!!That did it! I never even thought of that because my url pattern had a "rated/$" and it got to my view... AND the documentation on forms shows an action with no trailing slash for "create_form" so I never thought that a trailing slash was needed. see http://www.djangoproject.com/documentation/forms/ in the finished version of the "create_form" template it uses "action="." with no trailing slash. So, why is it that action="." as in the documentation with no trailing slash is ok but action="rated" isn't ok? Is "." a special case (if so, then why use that in the documentation as the example of how to do a change_form), or is the finished version of the change_form wrong? -- Glenn --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: why is my view for a submitted form not getting a POST?
What is happening is that Django is redirecting your request from "rating" to "rating/" (which is the correct location). Unfortunately POST information is lost in this redirect. On 3/9/06, Glenn Tenney <[EMAIL PROTECTED]> wrote: I've taken a working template and a working detail view and addeda form to that template AND another view to handle that form whensubmit gets clicked.In my template I've got: Rating: ="" /> 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 exceptionto 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 ... GETNo GET data POST No POST data I thought that clicking on the SUBMIT button would be a post methodand that request.POST would be true (and POST would bepopulated)... 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 -~--~~~~--~~--~--~---
Re: why is my view for a submitted form not getting a POST?
Please check this document http://code.djangoproject.com/wiki/NewbieMistakes It seems that you lost a '/' after action name "rated". -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---