Couple more things I discovered...

This page documents a RequiredIfOtherFieldsNotGiven validator that
doesn't actually exist!
http://www.djangoproject.com/documentation/forms/#validators (it's
close to what you want but not exactly -- you want it to be required if
*neither* of the other fields are given).

Maybe I'll submit a patch that actually adds both to
django.core.validators...

Anyway, I thought of a better way to write that validator! Scrap that
class and import...

def RequiredIfNoneGiven(other_fields, error_message=None):
   from django.core.validators import RequiredIfOtherFieldNotGiven,
AnyValidator, gettext_lazy
   from django.utils.text import get_text_list
   if error_message is None:
       error_message = "If this field is not given, %s must be given."
% get_text_list(other_fields)
   validators = [RequiredIfOtherFieldNotGiven(field) for field in
other_fields]
   return AnyValidator(validators, gettext_lazy(error_message))


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to