Skip to content

Instantly share code, notes, and snippets.

@SmileyChris
Created June 14, 2012 01:42
Show Gist options
  • Save SmileyChris/2927652 to your computer and use it in GitHub Desktop.
Save SmileyChris/2927652 to your computer and use it in GitHub Desktop.
def get_form_kwargs(request):
"""
A simple helper which returns the correct kwargs when a POST request is
used.
Usage::
form = MyForm(**get_form_kwargs(request))
if form.is_valid():
...
"""
if request.method == 'POST':
return {'data': request.POST, 'files': request.FILES}
return {'data': None, 'files': None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment