The redirect method isn't working.  I use middleware to insert a form
into the context for each page.  When I try to redirect with a
fragment identifier, then the page scrolls but I don't see the form
errors.  If I remove the error form redirect then I see the errors but
this removes the scroll.

Here is my code:
---------------------------------------------------------------
class reqInfoMiddleWare(object):
    """
    inserts the req info form in content and also handles form
processing

    based on: 
http://stackoverflow.com/questions/2734055/putting-a-django-login-form-on-every-page
    """

    def process_request(self, request):
        if request.method == 'POST':

            form = forms.reqInfo(request.POST)

            if form.is_valid():
                    form.save()

                    return HttpResponseRedirect('/thanks')

            else:
                #if error then scroll to where the form is
                return HttpResponseRedirect(request.path +
'#learnMoreId')

        else:
                form = forms.reqInfo()

        # attach the form to the request so it can be accessed within
the templates
        request.req_info_form = form

---------------------------------------------------------------

With this, I see the scroll but my form errors aren't being shown.  In
my form template I have <{% if form.errors %}>.

If I comment out the line < return HttpResponseRedirect(request.path +
'#learnMoreId')> and the else before it, then I get the scroll but I
don't get the form errors.

I'm developing on Django 1.3.

I don't want to use the iframe since it is going to make resizing the
form for errors difficult.  I prefer to stay away from javascript and
ajax if possible.  I also thought redirect with just a url was a
shortcut for  HttpResponseRedirect so it does the same thing.

Thank you for your help!!!!!!

Brian

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to