cant pass the "CSRF verification failed. Request aborted." error
Does it say why?
and looks like if you use the "render" function should be the easiest way since will take care of everything.I also tried removing the tags from the html and I still get the error.
Exactly. Does this work?
return render(request, "vote_form.html", {"all_restaurants": all_restaurants, "form": form})
2 extra questions.
can I use my own forms with django done in a html file? or they have to be django forms? (as I understand the django forms are premade so its easy to use them and render the widget? like a calendar widget)
Yes, you can do whatever you want :) The built in django forms are especially helpful for validating the data in the back end, but even if you do that, you can still hand-code the html.
now that I have the form and the submit how can I pass the info of the form to the next webpage, exampleso it say thank you for voting + the email they typed in the form.
There are a few ways to do it that I can think of:
For simplicity, I usually do something like redirect them to: /thanks/?email={{ their email }}. Then I can use that info in the template.
You could also store their email address in request.SESSION.
You could use the messages framework. https://docs.djangoproject.com/en/dev/ref/contrib/messages/
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e29b1a3c-4619-4b70-a55f-fd1b9315ae42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment