3👍
✅
You can override the add_view
, change_view
and changelist_view
model admin methods.
from django.contrib.auth.admin import UserAdmin
class MyUserAdmin(UserAdmin):
def add_view(self, request, form_url='', extra_context=None)
extra_context = extra_context or {}
extra_context['Sched_today'] = date.today()
return super(MyUserAdmin, self).add_view(request, form_url, extra_context)
It is important to subclass UserAdmin
, otherwise you will have problems with passwords. Remember to unregister the User
model first before registering your own model admin.
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
Source:stackexchange.com