Hi all I'm having problems working out how to pass messages to a form when using a Redirect. One example I found on the web of a Contact form set a variable message='Contact Added' or message='Contact Updated' depending on what happened. This example didn't use any Redirect after a POST.
Many sites strongly suggest to use a HttpResponseRedirect after a POST to cover the situation of a user hitting the back button and inadvertently making a double POST and it also can return one to a default page. However as you will glean from the code below if I have the HttpResponseRedirect then the form will only ever show 'Please fill in the details.' The form will never display any of the other messages. If I comment out the HttpResponseRedirect some of the other messages will show. How do Django users manage to provide action specific feedback messages to users on form submission? What should I be doing instead of what I have below? # Default form ContactForm = forms.form_for_instance(contact) form = ContactForm() message = 'Please fill in the details.' if request.POST: if request.POST['submit_action'] == 'Update': update_form = ContactForm(request.POST) if update_form.is_valid(): update_form.save() message = 'Update done.' else: message = 'Form was not valid!' else: message = 'Some other error message.' return HttpResponseRedirect("%s" % request.path) data = { 'request': request, 'message': message, 'form': form.as_table(), } return render_to_response('test_form_for_instance.html', data) Mike -- Michael Lake --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---