It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,
visit the help center。
已关闭8年。
在管理界面中创建用户时,我需要将is_staff值设置为True。
我怎样才能做到这一点?
谢谢
您可以定义一个自定义ModelAdmin并在其中添加自定义逻辑:
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)
您可以阅读有关它的更多信息
here。
我是一名优秀的程序员,十分优秀!