如何在我的主页 URL 上提供 allauth 的身份验证?
How do I make allauth's authentication available on my homepage URL?
所以我安装了 Django allauth 来处理我的登录身份验证。但是我不想使用单独的 URL 进行登录。我希望它可以通过 Javascript onclick 在我的主页上使用(当您单击 button/no 页面刷新时会出现登录框)。但当前的 allauth URL 位于“/accounts/login”。所以正如我所说,我需要它位于'/'。我该怎么做?
这是我的views.py:
def boxes_view(request):
...
search = request.GET.get('search')
posts = Post.objects.all().filter(category=1).order_by('-date')
if search:
posts = posts.filter(
Q(title__icontains=search) |
Q(content__icontains=search)
)
else:
posts = Post.objects.all().filter(category=1).order_by('-date')
context = {
'posts': posts,
}
return render(request, 'polls.html', context)
我可以将它作为上下文传递吗?怎么做到的?
听起来您希望用户能够使用您主页上的模式登录,或者您当前在转到“/”时看到的内容
如果是,则不要更改 allauth 登录 url。而是更改登录框的 javascript 代码以显示给定的内容 here.
另见 this answer。
所以我安装了 Django allauth 来处理我的登录身份验证。但是我不想使用单独的 URL 进行登录。我希望它可以通过 Javascript onclick 在我的主页上使用(当您单击 button/no 页面刷新时会出现登录框)。但当前的 allauth URL 位于“/accounts/login”。所以正如我所说,我需要它位于'/'。我该怎么做?
这是我的views.py:
def boxes_view(request):
...
search = request.GET.get('search')
posts = Post.objects.all().filter(category=1).order_by('-date')
if search:
posts = posts.filter(
Q(title__icontains=search) |
Q(content__icontains=search)
)
else:
posts = Post.objects.all().filter(category=1).order_by('-date')
context = {
'posts': posts,
}
return render(request, 'polls.html', context)
我可以将它作为上下文传递吗?怎么做到的?
听起来您希望用户能够使用您主页上的模式登录,或者您当前在转到“/”时看到的内容
如果是,则不要更改 allauth 登录 url。而是更改登录框的 javascript 代码以显示给定的内容 here.
另见 this answer。