Skip to content

Instantly share code, notes, and snippets.

@dstegelman
Created March 20, 2013 21:22
Show Gist options
  • Save dstegelman/5208592 to your computer and use it in GitHub Desktop.
Save dstegelman/5208592 to your computer and use it in GitHub Desktop.
Access request object inside of a form
#Form
class MyForm(forms.Form):
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
super(MyForm, self).__init__(*args, **kwargs)
def clean(self):
#... access the request object via self.request ...
#and in your view:
# Inside the view
myform = MyForm(request.POST, request=request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment