[Django] #33619: Proxy model does not inherite indexes and constraints from base model

42 views
Skip to first unread message

Django

unread,
Apr 6, 2022, 2:14:57 AM4/6/22
to django-...@googlegroups.com
#33619: Proxy model does not inherite indexes and constraints from base model
-------------------------------------+-------------------------------------
Reporter: xcoderl | Owner: nobody
Type: | Status: new
Uncategorized |
Component: | Version: 3.2
contrib.admin | Keywords: multiple model
Severity: Normal | admin
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi,

I am trying to enable multiple model admins for one model. Here is the
scenario:

1) I have a model called A that has "abstract = true";
2) I have a model called B that inherits model A, which has all the
fields, constraints, indexes, etc. under Meta;
3) I have a model admin for model B and everything works as expected.
4) Now, I want to create another model admin for model B. The solution is
to utilize a proxy model C to B as suggested at the following link,
https://stackoverflow.com/questions/2223375/multiple-modeladmins-views-
for-same-model-in-django-admin

The problem is that the proxy model C does not inherit constraints,
indexes from model B. And my app has some extra logic to check index and
constraint definition, the absence of which caused some problems
apparently.

It is intended behavior of proxy model? If it is, is there any other way
to create multiple admins for one model?

Thanks very much,
Jaska

--
Ticket URL: <https://code.djangoproject.com/ticket/33619>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 6, 2022, 2:25:13 AM4/6/22
to django-...@googlegroups.com
#33619: Proxy model does not inherite indexes and constraints from base model
-------------------------------------+-------------------------------------
Reporter: Jaska Lee | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution:
Keywords: multiple model | Triage Stage:
admin | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Jaska Lee:

Old description:

> Hi,
>
> I am trying to enable multiple model admins for one model. Here is the
> scenario:
>
> 1) I have a model called A that has "abstract = true";
> 2) I have a model called B that inherits model A, which has all the
> fields, constraints, indexes, etc. under Meta;
> 3) I have a model admin for model B and everything works as expected.
> 4) Now, I want to create another model admin for model B. The solution is
> to utilize a proxy model C to B as suggested at the following link,
> https://stackoverflow.com/questions/2223375/multiple-modeladmins-views-
> for-same-model-in-django-admin
>
> The problem is that the proxy model C does not inherit constraints,
> indexes from model B. And my app has some extra logic to check index and
> constraint definition, the absence of which caused some problems
> apparently.
>
> It is intended behavior of proxy model? If it is, is there any other way
> to create multiple admins for one model?
>
> Thanks very much,
> Jaska

New description:

Hi,

I am trying to enable multiple model admins for one model. Here is the
scenario:

1) I have a model called A that has "abstract = true";
2) I have a model called B that inherits model A, which has all the
fields, constraints, indexes, etc. under Meta;
3) I have a model admin for model B and everything works as expected.
4) Now, I want to create another model admin for model B. The solution is
to utilize a proxy model C to B as suggested at the following link,
https://stackoverflow.com/questions/2223375/multiple-modeladmins-views-
for-same-model-in-django-admin

The problem is that the proxy model C does not inherit constraints,
indexes from model B. And my app has some extra logic to check index and
constraint definition, the absence of which caused some problems
apparently.

Is it intended behavior of proxy model? If it is, is there any other way


to create multiple admins for one model?

Thanks very much,
Jaska

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33619#comment:1>

Django

unread,
Apr 6, 2022, 2:38:21 AM4/6/22
to django-...@googlegroups.com
#33619: Proxy model does not inherite indexes and constraints from base model
-------------------------------------+-------------------------------------
Reporter: Jaska Lee | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: multiple model | Triage Stage:
admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Please don't use Trac as a support channel. You should start from checking
[https://docs.djangoproject.com/en/4.0/topics/db/models/#meta-inheritance
docs] about `Meta` inheritance.

If you're having trouble understanding how Django works, see
TicketClosingReasons/UseSupportChannels for ways to get help.

--
Ticket URL: <https://code.djangoproject.com/ticket/33619#comment:2>

Django

unread,
Apr 6, 2022, 3:48:29 AM4/6/22
to django-...@googlegroups.com
#33619: Proxy model does not inherite indexes and constraints from base model
-------------------------------------+-------------------------------------
Reporter: Jaska Lee | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: multiple model | Triage Stage:
admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jaska Lee):

alright, thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/33619#comment:3>

Django

unread,
Apr 7, 2022, 12:46:38 AM4/7/22
to django-...@googlegroups.com
#33619: Proxy model does not inherite indexes and constraints from base model
-------------------------------------+-------------------------------------
Reporter: Jaska Lee | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: wontfix

Keywords: multiple model | Triage Stage:
admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jaska Lee):

* resolution: invalid => wontfix


Comment:

hello,

Specific meta inheritance on the proxy model does not solve the problem.
The indexes and constraints from the base model are still missing in the
proxy model, while other attributes seem to be successfully inherited. The
Django version is 3.2.2.

I am not necessarily looking for a solution for a use case here. The
solution is clear. I was just trying to indicate how the problem occurred.

The issue seems be rather platform related which might be worth of looking
into.

thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/33619#comment:4>

Reply all
Reply to author
Forward
0 new messages