Hi Merrick,
> How can I access request.user in a clean method of a ModelForm?
>
> class UserEmailForm(ModelForm):
> ...
>
You can instantiate your form passing the request or the user as
argument:
class UserEmailForm(ModelForm):
def __init__(self, *args, **kw):
self.request = kw.pop('request')
super(UserEmailForm, self).__init__(*args, **kw)
def clean_some_field(self):
print self.request.user
...
form = UserEmailForm(request.POST, request=request)
Best regards,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---