错误:/admin/login/,预期:/accounts/login/

Wrong: /admin/login/, Expected: /accounts/login/

Django==3.0.8

django-comments-xtd==2.6.2

views.py

@csrf_protect
@login_required
def like(request, comment_id, next=None):
    """
    Like a comment. Confirmation on GET, action on POST.

    Templates: :template:`django_comments_xtd/like.html`,
    Context:
        comment
            the flagged `comments.comment` object
    """
    comment = get_object_or_404(get_comment_model(), pk=comment_id,
                                site__pk=get_current_site_id(request))
    if not get_app_model_options(comment=comment)['allow_feedback']:
        ctype = ContentType.objects.get_for_model(comment.content_object)
        raise Http404("Comments posted to instances of '%s.%s' are not "
                      "explicitly allowed to receive 'liked it' flags. "
                      "Check the COMMENTS_XTD_APP_MODEL_OPTIONS "
                      "setting." % (ctype.app_label, ctype.model))
    # Flag on POST
    if request.method == 'POST':
        perform_like(request, comment)
        return next_redirect(request,
                             fallback=next or 'comments-xtd-like-done',
                             c=comment.pk)
    # Render a form on GET
    else:
        flag_qs = comment.flags.prefetch_related('user')\
            .filter(flag=LIKEDIT_FLAG)
        users_likedit = [item.user for item in flag_qs]
        return render(request, 'django_comments_xtd/like.html',
                      {'comment': comment,
                       'already_liked_it': request.user in users_likedit,
                       'next': next})

问题

当隐身用户按赞按钮时,他们将被重定向到 http://localhost:8000/admin/login/?next=/%5Ecomments/like/3/

我希望它被重定向到 http://localhost:8000/accounts/login/

settings.pyLOGIN_URL 不存在

我不确定这个 admin/login 来自哪里。接下来我可以尝试什么?

在你的INSTALLED_APPS,在settings.py, 如果 django.contrib.auth 在你的应用之上,DJANGO 将呈现默认的 auth , 所以你应该做的是将你的应用程序放在 django.contrib.auth 之上,这样 DJANGO 就会首先呈现你的应用程序。

对我有用