Hello,
  I have a form that accepts some data. If the data is invalid, the
server side validation should detect this, redirect to the original
url and display error messages.

  I have got this working but the problem is that I had to pollute the
request.sessions object with a lot of error  messages as that is the
only way the redirected page has access to the error messages. (I
don't want to use render_to_response etc as the url shows up
differently) e.g.

if request.method == 'POST':
      flight_search_form = FlightSearchForm(request.POST)
      if not flight_search_form.is_valid():

         if flight_search_form.errors.has_key('departureSrc'):
            request.session['departureSrc_errorMsg'] =
flight_search_form.errors['departureSrc'].as_text()
         if flight_search_form.errors.has_key('departureDst'):
            request.session['departureDst_errorMsg'] =
flight_search_form.errors['departureDst'].as_text()

         return HttpResponseRedirect('/')

I have a lot of fields on the main form and I think dumping all these
error messages into a session variable is pretty lame. I read up about
Messages, but they can be used only for authorized users not
anonymous, as per the docs.

Any elegant way to transmit error messages on a redirect?

thx
Jim


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to