I would like to un-register a ModelAdmin class from the default oscar app.
I created an admin.py file and did the following but was unable to obtain the desired result.
from django.contrib import admin
from oscar.apps.address.admin import *
admin.site.unregister(UserAddressAdmin)
admin.site.unregister(CountryAdmin)
The model is still displayed in the admin panel.
I want the model to be created but I do not want to display the same in the admin panel.
Any help would be greatly appreciated. Thanks.
admin.site.unregister
takes the Model
class that you want to unregister - you are passing it a ModelAdmin
class, which it will just ignore. This should work:
from oscar.core.loading import get_model
admin.site.unregister(get_model('address', 'useraddress'))
admin.site.unregister(get_model('address', 'country'))
However this is all unnecessary! Why don't you just put an empty admin.py
file in your fork of the app? Currently you are importing Oscar's admin registrations only to manually unregister all of them again. Just don't import them.