{{{
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.
* cc: jonas-django@… (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/21135#comment:1>
* 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>
* cc: kitsunde@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/21135#comment:3>
* cc: Petr Přikryl (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/21135#comment:4>