使用 Django 和 AllAuth 登录后不重定向到我自己的视图

Not redirecting to my own view after login with Django and AllAuth

我正在熟悉 Django,我正在尝试使用 django-allauth,我发现的问题是我无法在登录后重定向到我自己的视图。分享一段代码:

这是我在 login.html 模板中的表格:

<form action="{% url 'webapp:home' %}" method="post" class="margin-bottom-0">
            {% csrf_token %}
   ...
 </form>

这是我在我的应用程序中定义的 url.py:

app_name = 'webapp'

urlpatterns = [
    path(route='', view=views.HomeView.as_view(), name='home'),
]

我还定义了我的命名空间:

path("workspace/", include("picnic.webapp.url", namespace="webapp")), 

现在,每次登录成功,我都会收到 URL: http://127.0.0.1:8000/accounts/login/?next=/workspace/ which matches with login and it's redirecting me to the login page again... How can I force allauth to send me to http://127.0.0.1:800/workspace 而不是 url 当前发送给我?

此致

正在查看 documentation

表示您必须设置:

login_redirect_url 在您的设置中

并且您的登录表单存在问题,操作指定 url 表单发布到,allauth 的默认设置是:

action="{% url 'account_login' %}"

检查您是否将来自 allauth 的 urls 包含在基础中 urls.py:

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

编辑:

我猜 picnic.webapp.url 应该是 picnic.webapp.urls?