Adrian Holovaty wrote: > On 11/16/05, Robert Wittams <[EMAIL PROTECTED]> wrote: > >>For validation, we could do something like : >> >>from django.core import meta, validate >> >>class Poll: >> date = meta.DateTimeField() >> question = meta.CharField(maxlength=100) >> category = meta.ForeignKey(category) >> >> validate.fields(date,question).unique() # -> unique together >> validate.field(category).unique_for_month(date) > > > I'm not sure how this is an improvement. Putting the validator within > the field makes more sense, in my mind, and having a magic "validate" > object in the model class namespace is a bit strange. What problem > does this solve? >
Validation declaration is spread around. For validators that rely on just one field, validators are in the field. For validators that rely on multiple fields, they get defined according to some option in meta (of which there is currently only one, AFAIK) . The constructor calls for a field also can end up pretty unwieldy. I don't know what is "magic" about importing a python module.