是否可以将 Django HttpResponseRedirect 发送到 HTML 页面中的某个 ID?

Is it possible to send a Django HttpResponseRedirect but to a certain ID in the HTML page?

我有一个用户确认或拒绝报价的简单视图:

def confirmoffer(request, offerid):
    offer = Offer.objects.get(id = offerid)
    if 'confirm' in request.GET:

        offer.traveler_approval = True;
    else:
        offer.traveler_approval = False;
    offer.save()

    return HttpResponseRedirect("/dashboard#excursionoffers/")

我正在尝试 return 用户到她的仪表板,但到某个部分而不是页面的开头因此我这样做了:dashboard#excursionoffers/ 但是斜线会自动添加到外观像这样:

http://127.0.0.1:8000/dashboard/#excursionoffers/

呈现 id 无效。

这是仪表板的 url:

url(r'^dashboard/$', views.dashboard, name="dashboard"),

在您的 urls.py 中,您可能已经添加了这个 dashboard/$

删除末尾的斜杠,使其看起来像 dashboard$。可能有帮助