I need to override django-eav app admin class. In eav/admin.py
model is registered: admin.site.register(Value)
. I need to add list_display to this model. I know that it is bad practise to modify installed app code, so i need to override it. But, not sure how. In my own app/admin.py
i have:
class EavValueAdmin(ModelAdmin):
list_display = ('__unicode__', 'value_text', )
#unregistering class from eav.admin
admin.site.unregister(Value)
admin.site.register(Value, EavValueAdmin)
This gives me an error: NotRegistered: The model Value is not registered.
If i try to comment this line: admin.site.unregister(Value)
, also error: AlreadyRegistered: The model Value is already registered. How can i overcome this problem?
Django apps are loaded in the order they are listed in INSTALLED_APPS
in your settings.py
. Therefore your app
must come after django-eav
to be able to unregister it:
INSTALLED_APPS = [...
'django-eav',
...
'my_app',
]
Usually your apps must come after built-in and 3rd party apps. You have to test your project to see if everything works smoothly after changing the order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With