On Jan 23, 3:40 am, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Thu, 2009-01-22 at 17:27 -0800, mrts wrote: > > [....] > > > A > > side note: the `instance` attribute is not used in validator functions > > and I can't see a clear use case for it, so it looks like it can be > > removed -- prove me wrong please (I do see obscure corner cases where > > it could be useful -- if one needs to distinguish between forms and > > models in custom validators or do gettatr('something', instance), but > > these should really be handled in clean() manually). > > For models, the "instance" will the models "self" attribute. So that one > can do checks based on other information available on the model > instance. It's kind of the whole point behind the "model-aware" portion > of model-aware validation. > > Asking that everything like that gets pushed to clean() is being > awkward. clean() is for multi-field validation, the individual > validators are for single field validation. That doesn't mean the latter > cannot use other information available on the form.
As can be seen from the above, fields are already passed to validators via all_values = model_instance.__dict__.copy() for multi-field validation. But I agree that requiring to override clear() for anything more advanced is too restrictive, so let the instance be part of the signature. > I'll try and make time to look at this, along with other recent work in > this area, over the weekend. That would be most welcome, perhaps you can pop by #django-dev for more rapid idea exchange? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---