【问题标题】:Local settings not found : ModuleNotFoundError: No module named 'account'未找到本地设置:ModuleNotFoundError: No module named 'account'
【发布时间】:2021-10-19 01:00:46
【问题描述】:

我在 cmd 中遇到错误:

ModuleNotFoundError: 没有名为“帐户”的模块

以下是我遇到一些问题的代码。需要对命令或代码进行任何更改吗?

import account.form
from django import forms
 
class SignupForm(account.forms.SignupForm):

    def __init__(self, *args, **kwargs):
        super(SignupForm, self).__init__(*args, **kwargs)
        del self.fields["username"]


class UploadFileForm(forms.Form):
    file = forms.FileField()

【问题讨论】:

    标签: javascript python jquery django


    【解决方案1】:

    导入不正确。 account 属于您尚未导入的 allauth 包。试试这个

    from allauth import account
    from django import forms
     
    class SignupForm(account.forms.SignupForm):
    
        def __init__(self, *args, **kwargs):
            super(SignupForm, self).__init__(*args, **kwargs)
            del self.fields["username"]
    
    
    class UploadFileForm(forms.Form):
        file = forms.FileField()
    

    【讨论】:

    • 仍然显示相同的错误。即使在进行了必要的更改之后。
    • 请以文本格式提供完整的错误信息。你可以用它更新你的问题。
    【解决方案2】:

    我已经找到了这个问题的解决方案,很可能如果你遇到类似的问题,你需要为 django 用户帐户创建一个新模块并安装 python 包文件:pip install django-user-accounts

    【讨论】:

      猜你喜欢
      • 2022-12-27
      • 2022-12-27
      • 2022-12-19
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      • 2022-10-17
      • 2022-08-22
      相关资源
      最近更新 更多