Hi all, 

The question is how to add some validation statement in an upper/abstract 
class against all instances of subclasses.

here is the model

*class UpperAbstract(models.Model):*
*
*
*  def verifyUnique(value):*
*    if value:*
*      len(UpperAbstract.objects.filter(myuniquefield=value)) > 0:*
*         raise ValidationError(...)*
*
*
*  myuniquefield = CharField(max_length=15, 
blank=True,validators=[verifyUnique]))*
*
*
*  class Meta:*
* abstract = True*
*
*
*class Foo(UpperAbstract):*
*      myFoofield = CharField(max_length=15)*
*
*
*class Bar(UpperAbstract):*
*      myBarfield = CharField(max_length=15)*


Validation and store of any instance of *Foo* or *Bar* is failing as *
UpperAbstract* do not have *objects* attribute.
I can imagine why  but my question is then how to achieve this type of 
validation ? 

PS : my first goal was to be able to define field as 'unique if not None'.

thank in advance 
Regards
manu


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YnDGsZ-wuhwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to