Ik heb mijn antwoord bijgewerkt om alle kindermodellen te doorzoeken. Dat is maar een manier om de lijst met modellen te bouwen. Dit hangt af van uw gebruik.
U kunt waarschijnlijk iets in die zin doen (nog steeds niet getest):
class BaseArticle(models.Model):
title = models.CharField(max_length=512)
author = models.ForeignKey(User)
content = models.TextField()
_childrens = set()
# register the model on init
def __init__(self, *args, **kwargs):
super(BaseArticle, self).__init__(*args, **kwargs)
BaseArticle._childrens.add(self.__class__)
def save(self, *args, **kwargs):
for model in BaseArticle._childrens:
query = model.objects.filter(title=self.title, author=self.author, content=self.content)
# if this Article is already saved, exclude it from the search
if self.pk and model is self.__class__:
query.exclude(pk=self.pk)
if query.count():
# there's one or more articles with the same values
do_something()
break
super(BaseArticle, self).save(*args, **kwargs)
class Meta:
abstract = True