#22740: Multi-table inheritance gets Meta from abstract ancestor model class
-------------------------------+--------------------
Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I'm getting this validation error:
{{{
CommandError: One or more models did not validate:
places.restaurant: "index_together" refers to name. This is not in the
same model as the index_together statement.
places.restaurant: "index_together" refers to address. This is not in the
same model as the index_together statement.
}}}
From the following models:
{{{#!python
from django.db import models
class AbstractPlace(models.Model):
name = models.CharField(max_length=50)
address = models.CharField(max_length=80)
class Meta:
abstract = True
index_together = (('name', 'address'),)
class Place(AbstractPlace):
pass
class Restaurant(Place):
serves_hot_dogs = models.BooleanField()
serves_pizza = models.BooleanField()
}}}
Seemingly, the concrete model `Place` ends up with the inherited `Meta`
from the abstract parent. After the `Place` model class is created, during
`ModelBase.__new__`), any `Meta` (declared or inherited) should not be
there for concrete classes.
This way, models would never have a `Meta` (unless the modified and
explicitly added Meta, if they're abstract). I added `new_class.Meta =
None` just above `new_class._prepare()` in `ModelBase` and that properly
fixes the issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/22740>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.00896777d8d37e82448f09a0935296fe%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.