Advertisement
Guest User

Django proposal: bind Form late

a guest
May 28th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def contact(request):
  2.     form = FlexiForm(ContactForm, kwargs={'prefix': 'something-%s' % (some_id,), 'label_suffix': ': ',})
  3.     if request.method == 'POST':
  4.         form.bind(request.POST)  # substitutes internal ContactForm() with ContactForm(request.POST)
  5.         if form.is_valid():
  6.            pass
  7.     else:
  8.         pass  # Form already instantiated!
  9.  
  10.     return render(request, 'contact.html', {
  11.         'form': form,
  12.     })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement