Created
November 30, 2012 00:03
-
-
Save Alir3z4/4172791 to your computer and use it in GitHub Desktop.
Override the init to pass the current user to the model form.
This file contains hidden or 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
class Formio(ModelForm): | |
def __init__(self, user=None, *args, **kwrags): | |
""" | |
Override the init to pass the current user | |
to the model form. | |
Then the current user will be passed to the form at | |
initializing time in views or any other situation where | |
``request`` is available. | |
""" | |
self._user = user | |
super(Formio, self).__init__(*args, **kwrags) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fuck it over!
Now with CBV it's easy to hack into forms ;)