KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
After I submit the form for the first time and then refresh the form it gets resubmitted and and I don't want that. Here's my form in template : <form action = "" method = "POST"> {% csrf_token %} {{ form.as_p }} <input type = "submit" value = "Shout!"/> </form> How can I fix this ? Here's my views: def index(request): shouts = Shout.objects.all() if request.method == "POST": form = GuestBookForm(request.POST) if form.is_valid(): cd = form.cleaned_data shout = Shout(author = cd['author'], message = cd['message']) shout.save() form = GuestBookForm() else: form = GuestBookForm() return render_to_response('guestbook/index.html', {'shouts' : shouts, 'form' : form }, context_instance = RequestContext(request))
Tags (comma-separated)
Save Edits
Cancel