Django allauth未为用户名字段呈现适当的模型和字段名称

2024-10-03 11:21:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我从django allauth得到这个,用于唯一用户名检查。你知道吗

%(model_name)s with this %(field_label)s already exists.

联机快速搜索显示电子邮件错误已解决,可以用以下内容覆盖:

from django.utils.translation import ugettext_lazy as _
from allauth.account.adapter import DefaultAccountAdapter

class CustomAccountAdapter(DefaultAccountAdapter):
   # Overrides default adapter
   def __init__(self, request=None):
        super(CustomAccountAdapter, self).__init__(request)
        self.error_messages['email_taken'] = _('A user is already registered with this e-mail address.')

但是,以这种方式重写适配器对username不起作用。谁能帮我一下吗,这是唯一阻止我现在直播的东西。。。你知道吗


Tags: djangofromimportselfadaptermodelinitrequest