Where can I change the admin view code for a third-party application?

I am using a third-party application in my django webapp. But I want to customize the admin view for one of the third-party application models. The setup is more than changing the template change_list.htmlie I will need to add code to talk to an external web service, etc.

However, I do not want to modify a third-party application. Instead, I want to override it. How do I override ModelAdminfor a model that comes from a third-party application?

+5
source share
1 answer

This should help you:

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 often use this to configure UserAdmin as shown in this answer .

+17
source

All Articles