django-allauth 未捕获的引用错误

3 投票
2 回答
1421 浏览
提问于 2025-04-18 02:14

我搞不懂为什么我会遇到这个问题:

未捕获的引用错误:allauth未定义

...当我点击这个Facebook链接时:https://obscure-harbor-7751.herokuapp.com/accounts/signup/,这个网站托管在Heroku上。页面上没有相关的JavaScript代码,但我不知道allauth应该在哪里处理这个问题。

我很确定所有相关的设置都是正确的(下面粘贴了)。我觉得之前是可以正常工作的,但最近不知道为什么突然不行了(可能是因为在部署时更新了某些要求)。我正在使用django-cookiecutter。

有没有人能告诉我可能是什么问题?我尝试了很多方法,也在网上找了一个实时示例,看看我应该期待什么样的JavaScript,但没有找到。

请帮帮我!

谢谢,

相关设置:


TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'django.core.context_processors.request',
    "allauth.account.context_processors.account",
    "allauth.socialaccount.context_processors.socialaccount",
    # Your stuff: custom template context processers go here
)

AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
)

INSTALLED_APPS += (
    # Needs to come last for now because of a weird edge case between
    #   South and allauth
    'allauth',  # registration
    'allauth.account',  # registration
    'allauth.socialaccount',  # registration
    'allauth.socialaccount.providers.facebook',
)

2 个回答

3

使用下面的内容可能会更好:

{% providers_media_js %}

参考链接:http://django-allauth.readthedocs.org/en/latest/templates.html

3

我需要在页面上添加:

{% include "socialaccount/snippets/login_extra.html" %}

templates/account/signup.html 文件里,这样页面上才能显示出 JavaScript 的内容。我原本以为这些内容应该已经包含在里面了。

撰写回答