【发布时间】:2020-10-25 08:40:18
【问题描述】:
我已经阅读了 UserCreationForm() 的官方文档。我正在尝试访问我在其他模型中创建的用户。我调用什么模型来访问我在 UserCreationForm() 中创建的用户?简而言之,它们是我可以调用以访问用户模型的默认身份验证模型吗?
【问题讨论】:
标签: django django-models django-authentication
我已经阅读了 UserCreationForm() 的官方文档。我正在尝试访问我在其他模型中创建的用户。我调用什么模型来访问我在 UserCreationForm() 中创建的用户?简而言之,它们是我可以调用以访问用户模型的默认身份验证模型吗?
【问题讨论】:
标签: django django-models django-authentication
我应该调用什么模型来访问我在
UserCreationForm()中创建的用户?
正如我们在source code [GitHub] 中看到的,它使用User 模型:
from django.contrib.auth.models import User # … class UserCreationForm(forms.ModelForm): # … class Meta: model = User fields = ("username",) field_classes = {'username': UsernameField} # …
因此,您可以使用以下方法导入此模型:
from django.contrib.auth.models import <b>User</b>
documentation on the User 指定在此模型上定义的字段和方法。
【讨论】: