Inheriting from multiple ABCs do not follow the MRO for its abstract Managers

49 views
Skip to first unread message

Aron Podrigal

unread,
Feb 9, 2016, 4:26:01 AM2/9/16
to Django developers (Contributions to Django itself)
While going through the code for ModelBase for reviewing [1] it is unclear to me when inheriting from 2 Abstract models which define Managers, if the concrete model should use the first manager according to the creation counter or it should follow the MRO. I would expect the following test to pass. I would appreciate if someone can confirm that this is a bug so we should open a trac ticket and fix this.


@isolate_apps('managers_regress')
def test_multi_abstract_model_inheritance_manager_mro(self):

from django.db.models.manager import Manager

class Manager1(Manager):
pass

class Manager2(Manager):
pass

class AbstractModel1(models.Model):
custom_manager = Manager1()

class Meta:
abstract = True

class AbstractModel2(models.Model):
custom_manager = Manager2()

class ConcreteModel(AbstractModel2, AbstractModel1):
pass

self.assertIsInstance(ConcreteModel.custom_manager, Manager2)
self.assertIsInstance(ConcreteModel._default_manager, Manager2)

 

Podrigal, Aron

unread,
Feb 9, 2016, 4:28:59 AM2/9/16
to Django developers (Contributions to Django itself)

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/8e267ae3-bd78-40d7-aceb-bddb3e98e317%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Aron Podrigal
-
'1000001', '1110010', '1101111', '1101110'   '1010000', '1101111', '1100100', '1110010', '1101001', '1100111', '1100001', '1101100'

P: '2b', '31', '33', '34', '37', '34', '35', '38', '36', '30', '39', '39'

Reply all
Reply to author
Forward
0 new messages