Opened 10 years ago
Closed 10 years ago
#23779 closed Bug (invalid)
Can't use unique_together if one of the fields is in a mixin
Reported by: | Tom Carrick | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Slightly related to https://code.djangoproject.com/ticket/16732
I have a mixin:
class PublishableMixin(object): publish_date = models.DateTimeField()
and a model I wish to use it in:
class Article(PublishableMixin, models.Model): slug = models.SlugField() class Meta: unique_together = ('publish_date', 'slug')
This fails at the system check level:
news.Article: (models.E012) 'unique_together' refers to the non-existent field 'publish_date'.
Note:
See TracTickets
for help on using tickets.
You need to use abstract models as described in the documentation (not inherit from
object
). If something isn't clear there about that, could you open a documentation ticket? Thanks!