Hi,
actually I am facing the same problem here. I did quite a search on
the subject and I found no real solution to this use case. Here are my
models:
---
contacts/models.py:
class Address(models.Model):
street = models.CharField(max_length=255)
city = models.CharField(max_length=255)
region = models.CharField(max_length=255)
...
contacts/admin.py:
class AddressInline(admin.StackedInline):
model = Address
extra = 0
location/models.py:
class Location(models.Model):
address = models.ForeignKey(Address)
location/admin.py:
class LocationAdmin(admin.ModelAdmin):
inlines = [AddressInline,]
other/models.py:
class Other(models.Model):
address = models.ForeignKey(Address)
other/admin.py
class OtherAdmin(admin.ModelAdmin):
inlines = [AddressInline,]
---
The point is that the address is used in several other models and will
be used in even more models in the future. And it should definitely
not know about those other models.
Now in order to display the address admin fields inline on the
"Location" and "Other" model I need to overload some functions of the
LocationAdmin or OtherAdmin class. This is not an easy task and it
could be speed up by making the reverse inline admin work.
I think this is not an esoteric use case, so this might not be
"twisting the admin interface beyond intended usage". But as I am not
that much experienced with database design I wonder if there is some
other way to code the above models in order to get the address into
the admin pages of the other model (by using existing Django admin
features).
Regards,
Peter Eschler
On 10 Jan., 02:13, Malcolm Tredinnick <
malc...@pointy-stick.com>
wrote: