Created
March 20, 2013 21:22
-
-
Save dstegelman/5208592 to your computer and use it in GitHub Desktop.
Access request object inside of a form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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