Monday, May 31, 2010

Re: Auto populate currently logged in user's user id in forms

I think that I figured it out ......... we can use commit=False then
get the user from request.user .......... am I correct ? ....... any
other way ??

On May 31, 6:03 pm, gvkalra <gvka...@gmail.com> wrote:
> Hi.
> Here what I have donehttp://github.com/gvkalra/showtime/blob/master/photo/views.py
>
> What I want to do is:
> Auto populate the database with currently logged in user's user id
> like it has been done with the date of creation of the record by
> using
> uploaded = models.DateField(auto_now_add=True)
>
> how to do that with:
> clicked_by = models.ForeignKey(User) ??
>
> something like
> clicked_by = models.ForeignKey(User.username, editable=False)
>
> {though it doesn't work, but just to demonstrate the idea} ........

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment