Opened 7 years ago

Closed 5 months ago

#11560 closed New feature (fixed)

let proxy models multiple-inherit from the same concrete base model

Reported by: rfk Owned by: akki
Component: Database layer (models, ORM) Version: master
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)

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.

Attachments (1)

multiple_proxy_models.diff (3.4 KB) - added by rfk 5 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 7 years ago by rfk

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 5 years ago by julien

  • 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.

Changed 5 years ago by rfk

comment:5 Changed 5 years ago by rfk

I've redone the patch against latest trunk and added a brief note in the proxy models documentaion.

comment:6 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 3 years ago by gzerone@…

Hi rfk, thanks for the patch file, it works for me. Hope the feature will work on master branch.

comment:9 Changed 21 months ago by Griatch

This has been lurking around for a long time, any idea when this might merge into master? The patch seems to have unittest information now and the feature itself is working. We would much like to use this feature without having to patch django itself.

comment:10 follow-up: Changed 21 months ago by timgraham

The patch needs to be updated to apply cleanly. If you can update it and send a pull request, that will help. Also a mention in the release notes and a .. versionchanged:: 1.8 annotation would be helpful. See our patch review checklist.

comment:11 Changed 10 months ago by auvipy

  • Owner changed from nobody to auvipy
  • Status changed from new to assigned
  • Version changed from 1.1-beta to master

comment:12 in reply to: ↑ 10 Changed 10 months ago by auvipy

Replying to timgraham:

The patch needs to be updated to apply cleanly. If you can update it and send a pull request, that will help. Also a mention in the release notes and a .. versionchanged:: 1.8 annotation would be helpful. See our patch review checklist.

Hi Tim,

Is this issue already resolved by other works ? or I should work on the patch to implement it cleanly?

comment:13 Changed 10 months ago by timgraham

I don't know of any work that would have resolved this ticket.

comment:14 Changed 5 months ago by akki

  • Owner changed from auvipy to akki

comment:15 Changed 5 months ago by akki

  • Patch needs improvement unset

comment:16 Changed 5 months ago by timgraham

  • Needs documentation unset
  • Patch needs improvement set

Left a few comments for improvement.

comment:17 Changed 5 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 49f95cc0:

Fixed #11560 -- Allowed proxy model multiple-inheritance from the same concrete base model.

Note: See TracTickets for help on using tickets.
Back to Top