On 1/17/07, serbaut <[EMAIL PROTECTED]> wrote:
Say for example that I need to check permissions for request.user in
clean?
def clean(self, value):
if request.user.has_some_property() and value > 100:
raise forms.ValidationError, 'You are not allowed to go that high,
please enter a value below 100.'
return value
If you need to validate a value from the request object, pass that
value in when you instantiate your form.
def my_view(request):
f = MyForm({'foo': request.POST['foo'], 'bar': request.user.username})
The form library itself knows nothing about request objects.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---