#11560: let proxy models multiple-inherit from the same concrete base model -------------------------------------+------------------------------------- Reporter: rfk | Owner: nobody Type: New | Status: new feature | Component: Database layer Milestone: | (models, ORM) Version: | Severity: Normal 1.1-beta-1 | Keywords: Resolution: | Has patch: 1 Triage Stage: Accepted | Needs tests: 0 Needs documentation: 1 | Patch needs improvement: 1 | -------------------------------------+------------------------------------- Changes (by julien):
* needs_better_patch: 0 => 1 * needs_docs: 0 => 1 Old description: > Currently proxy models are required to have a single concrete base model > class. Unfortunately this prevents me from combining several proxy > subclasses of the same model. In my particular use case, I have two > different apps that provide two different proxies of the standard User > model. To successfully use both apps I need to create another subclass > that combines the two, e.g: > > {{{ > class MyUser(App1User,App2User): > class Meta: > proxy = True > }}} > > This gives a TypeError: "Proxy model 'MyUser' has more than one non- > abstract model base class". But since App1User and App2User proxy the > same underlying model, there's no ambiguity introduced by this multiple > inheritance and I think it should be permitted. > > Attached is a simple patch to make this work, by permitting additional > concrete base classes if they are identical to the one that was already > found. New description: Currently proxy models are required to have a single concrete base model class. Unfortunately this prevents me from combining several proxy subclasses of the same model. In my particular use case, I have two different apps that provide two different proxies of the standard User model. To successfully use both apps I need to create another subclass that combines the two, e.g: {{{ class MyUser(App1User,App2User): class Meta: proxy = True }}} This gives a TypeError: "Proxy model 'MyUser' has more than one non- abstract model base class". But since App1User and App2User proxy the same underlying model, there's no ambiguity introduced by this multiple inheritance and I think it should be permitted. Attached is a simple patch to make this work, by permitting additional concrete base classes if they are identical to the one that was already found. -- Comment: The tests would need to be rewritten using unittests since this is now Django's preferred way. -- Ticket URL: <http://code.djangoproject.com/ticket/11560#comment:4> Django <http://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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.