Created
January 24, 2012 02:23
-
-
Save sleekslush/1667396 to your computer and use it in GitHub Desktop.
Adding request user to a form save
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 MyView(CreateView): | |
model = Team | |
def form_valid(self, form): | |
self.object = form.save(commit=False) | |
self.object.user = self.request.user | |
self.object.save() | |
return FormMixin.form_valid(self, form) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what I ended up with: https://gist.github.com/1674741