#16646: Only first meta inner class inherited with multiple abstract base
models.
-------------------------------------+-------------------------------------
Reporter: varikin | Owner: nobody
Type: Bug | Status: reopened
Milestone: | Component: Database layer
Version: 1.3 | (models, ORM)
Resolution: | Severity: Normal
Triage Stage: | Keywords:
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Comment (by aaugustin):
I understand that you would like the parents' `Meta` classes to be
magically merged to build the child `Meta` class. Unfortunately, as
pointed out in the first link I posted, for most options of `Meta` that
doesn't make sense. Even for `ordering`, there are several way you can
merge two values: take the first that isn't `None`, concatenate, etc.
You could request this feature but it's likely to get rejected on the
grounds of backwards-incompatibility.
----
Replying to [comment:2 varikin]:
> For starters, ordering was not copied over to the child class in the
first case.
You're using multiple inheritance, and the docs say that '''"if multiple
parents contain a Meta class, only the first one is going to be used, and
all others will be ignored."''' This is the second link I posted.
In your first case, the first `Meta` class contains no ordering. Hence the
child contains no ordering.
One way to understand this is as follows:
{{{
>>> class A(object):
... attr = "foo"
...
>>> class B(object):
... attr = "bar"
...
>>> class C(A, B):
... pass
...
>>> C.attr
'foo'
>>> class D(B, A):
... pass
...
>>> D.attr
'bar'
>>>
}}}
Just put `class Meta` instead of `attr` in this example, and hopefully you
will Django's behavior will look more natural.
You could also take a look at Python's behavior regarding `__metaclass__`
and multiple inheritance; it's a very similar problem.
Replying to [comment:2 varikin]:
> My examples use abstract base classes, so the Meta class should be
inherited.
That's true; I had forgotten that; please disregard my first sentence.
> This is a matter of when using abstract base classes, the meta is not
inherited for multiple abstract base classes.
Only the first one — see above.
----
So I still believe Django behaves according to the documentation, and
there isn't a bug here. Since I'm not really into close/reopen wars, I'll
let someone else decide what to do with this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/16646#comment:3>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.