def process_view request FormClass args kwargs if not FormClass return

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def process_view(request, FormClass, *args, **kwargs):
if not FormClass:
return None
if request.method == 'POST':
form = FormClass(data=request.POST, files=request.FILES, *args, **kwargs)
if form.is_valid():
obj = form.save()
raise RedirectException(obj.get_absolute_url())
else:
form = FormClass(*args, **kwargs)
return form