[Django] #21135: Admin: Support for editing OneToOne related models in RELATED model

14 views
Skip to first unread message

Django

unread,
Sep 21, 2013, 9:30:41 AM9/21/13
to django-...@googlegroups.com
#21135: Admin: Support for editing OneToOne related models in RELATED model
-------------------------------+--------------------
Reporter: jonash | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Consider these models:

{{{
class Person(models.Model):
address = models.OneToOneField("Address")

class Organization(models.Model):
address = models.OneToOneField("Address")

class Building(models.Model):
address = models.OneToOneField("Address")
}}}

Currently it's not possible to have a different `ModelAdmin` for each of
the above models because the `ModelAdmin.inlines` property works a
*reversed* manner.

Using the new feature would look like this (same `AddressAdmin` for every
model)

{{{
class AddressAdmin(admin.TabularInline):
model = Address

class PersonAdmin(admin.ModelAdmin):
inlines = [AddressAdmin]

class OrganizationAdmin(admin.ModelAdmin):
inlines = [AddressAdmin]

class BuildingAdmin(admin.ModelAdmin):
inlines = [AddressAdmin]
}}}

or even like this (different `AddressAdmin`)

{{{
class PersonAddressAdmin(admin.TabularInline):
model = Address

class OrganizationAddressAdmin(admin.TabularInline):
model = Address

class BuildingAddressAdmin(admin.TabularInline):
model = Address

class PersonAdmin(admin.ModelAdmin):
inlines = [PersonAddressAdmin]

class OrganizationAdmin(admin.ModelAdmin):
inlines = [OrganizationAddressAdmin]

class BuildingAdmin(admin.ModelAdmin):
inlines = [BuildingAddressAdmin]
}}}

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

Django

unread,
Sep 21, 2013, 9:31:35 AM9/21/13
to django-...@googlegroups.com
#21135: Admin: Support for editing OneToOne related models in RELATED model
-------------------------------+--------------------------------------

Reporter: jonash | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by jonash):

* cc: jonas-django@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Oct 22, 2013, 2:16:02 PM10/22/13
to django-...@googlegroups.com
#21135: Admin: Support for editing OneToOne related models in RELATED model
-------------------------------+------------------------------------

Reporter: jonash | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timo):

* version: 1.5 => master
* stage: Unreviewed => Accepted


Comment:

A better solution may be to use model inheritance and proxy models to
achieve what you are trying to accomplish.

Here's what Malcolm had to say in an [https://groups.google.com/d/topic
/django-users/QWMsXf-I-AE/discussion old thread on django-users]:

Maybe you could knock up a patch to make this work and maybe it's
worthwhile (I don't really have a strong opinion either way, beyond
thinking that there's really no end to people twisting the admin
interface beyond intended usage and perhaps the should re-evaluate their
use-cases). This is "scratch your own itch" territory, I suspect.

I agree with the above.

I also found some possible code on
[http://djangosnippets.org/snippets/2032/ djangosnipppets]. Tentatively
accepting the ticket.

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

Django

unread,
May 12, 2016, 5:43:14 AM5/12/16
to django-...@googlegroups.com
#21135: Admin: Support for editing OneToOne related models in RELATED model
-------------------------------+------------------------------------

Reporter: jonash | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by kitsunde):

* cc: kitsunde@… (added)


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

Django

unread,
Apr 22, 2021, 3:10:33 PM4/22/21
to django-...@googlegroups.com
#21135: Admin: Support for editing OneToOne related models in RELATED model
-------------------------------+------------------------------------
Reporter: Jonas H. | Owner: nobody

Type: New feature | Status: new
Component: contrib.admin | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Petr Přikryl):

* cc: Petr Přikryl (added)


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

Reply all
Reply to author
Forward
0 new messages