Skip to content

Instantly share code, notes, and snippets.

@Alir3z4
Created November 30, 2012 00:03
Show Gist options
  • Select an option

  • Save Alir3z4/4172791 to your computer and use it in GitHub Desktop.

Select an option

Save Alir3z4/4172791 to your computer and use it in GitHub Desktop.
Override the init to pass the current user to the model form.
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)
@Alir3z4

Alir3z4 commented Jan 6, 2013

Copy link
Copy Markdown
Author

Fuck it over!
Now with CBV it's easy to hack into forms ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment