简体   繁体   English

如何在继承 AbstractUser 后禁用密码以创建自定义用户

[英]how to disable password after inheriting AbstractUser to make a custom user

I followed what django docs said about inheriting AbstractUser to make a custom user for easy future changes我按照 django 文档所说的关于继承 AbstractUser 来创建自定义用户以方便将来的更改

https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project

Anyway, I have it now on the admin menu as a different page, it now looks like this无论如何,我现在在管理菜单上将它作为一个不同的页面,现在看起来像这样在此处输入图片说明

I basically want to disable that input (and others as well).我基本上想禁用该输入(以及其他输入)。 How do I do that?我怎么做?

I think you are searching for the readonly_fields and exclude attributes of ModelAdmin,我认为您正在搜索readonly_fieldsexclude ModelAdmin 的属性,

class MyModelAdmin(admin.ModelAdmin):
    readonly_fields = ('foo', 'bar')
    exclude = ('foo_bar',)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM