1 2 3 4 5 6 | def form_kwargs(request):
kwargs = {}
if request.method == 'POST':
kwargs['data'] = request.POST
kwargs['files'] = request.FILES
return kwargs
|
More like this
- Hidden Forms by insin 4 years, 10 months ago
- ImageField for admin with thumbnail by semente 2 years, 11 months ago
- SignedForm: CSRF-protect forms with a hidden token field by exogen 3 years, 8 months ago
- Form row filter by kylefox 4 years, 3 months ago
- A Lazy ChoiceField implementation by lsbardel 2 years, 7 months ago
Comments
Maybe its just me, but I don't see how this is "DRY"er. Not even sure what the point of it is.
#
Normally, you'd write:
Now you write:
#
PS: if you'd rather not bother with a helper like this, the method of instanciating a form only once for both cases is still useful.
The most simple case is (where files aren't involved and you always expect at least one thing in your POST):
#