On Sep 23, 12:53 am, Tai Lee <[EMAIL PROTECTED]> wrote: > On Sep 23, 9:27 am, Simon Willison <[EMAIL PROTECTED]> wrote: > > > The significant downside is that having a render() method on a form > > that performs the same function as render_to_response feels really, > > really strange. It's convenient, but it just doesn't feel right and > > I'm not sure I can justify it. > > How would this work when you have multiple forms/modelforms/formsets > on one page?
In that case, you'd have to fall back to the old way of doing things - form.render() would be a shortcut, not the only way of doing this. You'd probably end up with code that looked like this: def complex_view(request): form_one = FormOne(request) form_two = FormTwo(request) form_three = FormThree(request) if form_one.is_valid() and form_two.is_valid() and form_three.is_valid(): # Do something with their cleaned_data return HttpResponseRedirect("/done/") response = render_to_response('complex_view.html', { 'form_one': form_one, 'form_two': form_two, 'form_three': form_three }) form_one.protect(response) form_two.protect(response) form_three.protect(response) return response Since all form.protect(response) actually does is ensure that there's a csrf cookie, you should only actually have to do it once for one of the forms. Maybe it shouldn't be a form method at all in that case - maybe it should be a function called django.forms.protect(request, response) (request so it can check if the cookie has been set already, and response so it can set it if needed). Cheers, Simon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers?hl=en -~----------~----~----~----~------~----~------~--~---