我尝试使用反向,没有问题,有在django和当我看到的React,它只是空白
from django.shortcuts import render
from django.http import HttpRequest
from django.http import HttpResponse
from django.http import JsonResponse
from django.shortcuts import redirect
def Aviation (request):
return render(request, 'Aviation/Aviationtest.html')
def SendInformations (request):
#a lot of uninteresting code
return redirect(reverse("Aviation"))
这是我的urls.py文件
from django.urls import path
from . import views
urlpatterns = [
path("", views.Aviation, name="Aviation"),
path("let_me_send_informations", views.let_me_send_informations, name="let_me_send_informations"),
path("Informations", views.Informations, name="Informations"),
path("SendInformations", views.SendInformations, name="SendInformations")
]
我尝试使用reverse,完整路径,而不是使用reverse,我确信目录设置良好
2条答案
按热度按时间wgeznvg71#
来自文档:
将其更改为:
1hdlvixo2#
你可以使用redirect()方法而不需要反向操作,如下所示:
查看文档以了解更多信息:https://docs.djangoproject.com/en/4.1/topics/http/shortcuts/#redirect