Skip to content

Instantly share code, notes, and snippets.

@sleekslush
Created January 24, 2012 02:23
Show Gist options
  • Select an option

  • Save sleekslush/1667396 to your computer and use it in GitHub Desktop.

Select an option

Save sleekslush/1667396 to your computer and use it in GitHub Desktop.
Adding request user to a form save
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)
@dnoyes

dnoyes commented Jan 25, 2012

Copy link
Copy Markdown

Here's what I ended up with: https://gist.github.com/1674741

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