On Jul 14, 2009, at 2:50 PM, Viktor Semykin wrote:
>
> Hi everyone.
>
> I use django.views.generic.create_update.create_object to allow users
> to post new entries on my site.
> How can I make model automatically save the user currently logged in?
> Model like
> class MyModel(Model):
>user = ForeignKey(User)
> --~--~-~--~~~---~--~~
Set user = request.user in your view.
A slightly more "automatic" way of doing it would be
to override the save method of your model, but I think
you'd still have to pass the user instance into it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---