Django allauth: empty 'signup_url'

安稳与你 提交于 2019-12-12 03:55:53

问题


Using django 1.8.16 and package django-allauth==0.27.0

Login works fine, but signup page cannot be reached from login page.

The default login template 'login.html' contains a link to a signup page:

<p>{% blocktrans %}If you have not created an account yet, then please
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>

But since the value of 'signup_url' is empty, this points nowhere.

Question is: where should 'signup_url' get its value from?

django-allauth documentation doesn't mention this: http://django-allauth.readthedocs.io/en/latest/installation.html

More info:

  • 'mysite.com/user/login' works fine
  • 'mysite.com/accounts/signup' actually shows the signup page, so this is what 'signup_url' should refer to
  • Django debug toolbar doesn't work on this page, as one needs to be logged in for the toolbar to work?

Settings extract:

LOGIN_URL = reverse_lazy('login')
LOGOUT_URL = reverse_lazy('logout')
LOGIN_EXEMPT_URLS = (
    r'^about$',
    r'^accounts/password/reset/$',
    r'^accounts/signup/$',
)
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"

回答1:


This was caused by wrong url settings.

Working top level urls.py section:

url(r'^accounts/', include('allauth.urls')),
url('^', include('django.contrib.auth.urls')),


来源:https://stackoverflow.com/questions/41277989/django-allauth-empty-signup-url

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