Opened 15 years ago

Last modified 9 years ago

#11560 closed New feature

let proxy models multiple-inherit from the same concrete base model — at Version 4

Reported by: Ryan Kelly Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Julien Phalip)

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.

Change History (5)

comment:1 by Ryan Kelly, 15 years ago

Component: UncategorizedDatabase layer (models, ORM)

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:4 by Julien Phalip, 14 years ago

Description: modified (diff)
Needs documentation: set
Patch needs improvement: set

The tests would need to be rewritten using unittests since this is now Django's preferred way.

by Ryan Kelly, 14 years ago

Attachment: multiple_proxy_models.diff added
Note: See TracTickets for help on using tickets.
Back to Top