django-allauth: Module “accounts.forms” does not define a “SignupForm” class

自闭症网瘾萝莉.ら 提交于 2019-12-05 08:38:56

Just inherit from forms.Form and add the signup function.

class CustomSignupForm(forms.Form):
    def signup(self, request, user):
        pass

ACCOUNT_SIGNUP_FORM_CLASS = 'app.forms.CustomSignupForm'

Sir you are victim of Circular Import. allauth tries to import your custom signup form class from accounts.forms but in the same file you are importing from allauth from allauth.account.forms import BaseSignupForm. You don't need to extend your SignupForm from BaseSignupForm. Just create a simple form and allauth will automatically extend it for you.

I had this issue but it was not happening from the SignupForm class, (I referenced it correctly as @aamir suggested).

Instead, it was because I had LoginForm subclassed in the same file as the SignupForm class. For whatever reason, this was also causing a circular import. It also was only happening when I imported views while writing tests, not sure why.

I found this solution, which was to just give SignupForm its own forms.py file to live in and it fixed this issue.

Try importing SignupForm instead of BaseSignupForm from django-allauth.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!