Hi all,

related to work on #6845 I stumbled across an issue with validate_unique.

Currently it validates all the unique fields that are present on a
form and in cleaned_data. If the instance passed to the form has pk
set, it will exclude the model from the db lookup validating
uniqueness.

Since we moved validate_unique to model, we no longer can just test
for self.pk because of custom primary keys. The question is now: what
to do?

at http://github.com/HonzaKral/django/tree/model-validation I am
adding a property _new to the instance in ModelForm.__init__ so that
later in the model's validate_unique method I can check for it.

That works, but seems ugly. On IRC we also discussed the possibility
of an additional parameter to model.clean() or marking all models as
existing when constructed by the ORM and using that as source of this
piece of information.

What do you people think?

Thanks

Honza Král
E-Mail: honza.k...@gmail.com
ICQ#:   107471613
Phone:  +420 606 678585

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

Reply via email to