There are two custom ModelAdmins provided by contrib projects which I'd like to combine on a single model's administrative interface. How do I combine two or more ModelAdmins on a single model such that they both apply to the same administrative interface?
My particular scenario: I'm building a gis app using geodjango which keeps track of locations. My data model uses the models.PointField() type provided by geodjango. In order to be able to edit the location in the admin panel I registered my model using the admin.OSMGeoAdmin admin model.
admin.site.register(Prospect, admin.OSMGeoAdmin)
This now shows me a graphical location picker with a map, which is what I want. However, I want to import and export these objects. Typically I would use the import_export ModelAdmin for this, which looks like this:
class ProspectResource(resources.ModelResource):
class Meta:
model = Prospect
class ProspectIEAdmin(ImportExportModelAdmin):
resource_class = ProspectResource
admin.site.register(Prospect, admin.ProspectIEAdmin)
How do I combine these two ModelAdmins on the same model so that I can both set the location using the graphical map tool AND import and export the objects?
If I ago ahead and attempt to register them both like so:
admin.site.register(Prospect, admin.OSMGeoAdmin)
admin.site.register(Prospect, admin.ProspectIEAdmin)
I get the following error:
AttributeError: module 'django.contrib.gis.admin' has no attribute 'ProspectIEAdmin'
My question is distinct from "how do I have two separate ModelAdmins for the same model." My question is how to I combine two ModelAdmins into the same administrative panel. I am aware that I could use a proxy model to create two admin panels, one with a mapping tool and one with an export tool. But I want the mapping tool and the export tool registered together not separately.