Reputation: 245
I want to change admin classes programmatically without restarting server. I want to for example change list displays of a model in runtime. Now it only changes when I restart the server... Example (Versionadmin is an extention of modeladmin):
admin.site.unregister(model)
class YourModelAdmin(VersionAdmin):
list_display = new_list_display
admin.site.register(model, YourModelAdmin)
This works if I run it in admin.py, but if I run it when the admin site is already setup, nothing changes. Any idea how to go about this?
Upvotes: 0
Views: 43
Reputation: 3907
Have you tried reloading the module after you make changes? Python 3+
import importlib.reload as reload
reload(admin)
Python 2.7+
reload(admin)
Upvotes: 1