I need to set the is_staff value to True when creating a user in Admin interface.
How can I do that?
Thanks
You can define a custom ModelAdmin and add your custom logic there:
class UserAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
if request.user.is_superuser:
obj.is_staff = True
obj.save()
admin.site.register(User, UserAdmin)
You can read more about it here.
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