I have a ModelForm that has a field of User. I'd like this to be
automatically set to whichever user is logged in. I can think of only
one solution, passing request.user into the constructor of the form
and have save() set it, but it *does not work* for generic views,
since they need a form class that they want to instantiate themselves.

I also tried writing a subclass of my form within the view, and
passing in request.user as an object, but that was way too ugly. So I
thought the only way is to have the form retrieve the user object
itself, globally. Can this be done? If not, what other recourse do I
have in accomplishing this?

PS. How do I set a value inside a form's save() function anyway? When
there's an instance, it's just self.instance.field = value, but when
it's submitted unbound, there is no instance...

Thanks,
Oliver
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to