Suppose I have these models (non-practical code, it's just an example):
class BaseArticle(models.Model):
title = models.CharField(max_length=512)
author = models.ForeignKey(User)
content = models.TextField()
class Meta:
abstract = True
class ArticleWithColor(BaseArticle):
color = models.CharField(max_length=512)
class ArticleTypeWithSmell(BaseArticle):
smell = models.CharField(max_length=512)
When saving an Article (Color or Smell article), I would like to check whether there are any other existing instances that have the same values for the shared fields (those being the BaseArticle fields).
In other words: how can I check whether there already exists an ArticleWithColor with the same values for the fields it has inherited from BaseArticle as the ArticleWithSmell I'm about to save?