I have a situation (the shopping cart checkout sequence) where the workflow used in the application to create Django FormPreview looks perfect, except that I need to have some presentation logic before I call it (I cannot call the sequence check if the basket is empty, for example). From docs, it looks like you are calling FormPreview directly from urlconf like this:
(r'^post/$', SomeModelFormPreview(SomeModelForm))
... and it calls the overridden done () method for FormPreview directly (without submission).
Since my urls.py is like:
url(r'^checkout/$', 'checkout', {'SSL': settings.ENABLE_SSL }, name = 'checkout'),
and my view is similar to:
def checkout(request):
if cart.empty(request):
cart = urlresolvers.reverse('shopping_cart')
return HttpResponseRedirect(cart)
if request.method == 'POST':
checkoutform = CheckoutFormPreview(CheckoutForm)
This last line is where I would like to name it, but I canโt figure out how to wrap it ... Suggestions?
source