1👍
✅
Just change user creation form for admin and work your magic there:
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserChangeForm
class CustomUserChangeForm(UserChangeForm):
def save(self, force_insert=False, force_update=False, commit=True):
m = super(CustomUserChangeForm, self).save(commit=False)
# do custom stuff
if commit:
m.save()
return m
class CustomUserAdmin(UserAdmin):
form = CustomUserChangeForm
admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
Source:stackexchange.com