Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I modify the admin view code for a 3rd party app?

Tags:

django

I am using a 3rd party app in my django webapp. But I want to customize the admin view for one of the models in the 3rd party app. The customization is more than changing the change_list.html template i.e. I will need to add code to talk to an external webservice etc.

However, I don't want to modify the 3rd party app. Instead I want to override it. How I override the ModelAdmin for a model that comes from a 3rd party app ?

like image 403
canadadry Avatar asked Feb 17 '12 02:02

canadadry


1 Answers

This should get you started:

from django.contrib import admin
from thirdpartyapp.models import ThirdPartyModel
from thirdpartyapp.admin import ThirdPartyAdmin

class CustomThirdPartyAdmin(ThirdPartyAdmin):
    pass


admin.site.unregister(ThirdPartyModel)
admin.site.register(ThirdPartyModel, CustomThirdPartyAdmin)

I use this often to customize the UserAdmin as shown in this answer.

like image 156
Trey Hunner Avatar answered Dec 31 '22 01:12

Trey Hunner