Django path路径报错
Django path 错误
错误:
RuntimeError at /calculate
You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set. Django can’t redirect to the slash URL while maintaining POST data. Change your form to point to localhost:8000/calculate/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
学习Django时第一次调用动态显示页面,前端使用POST方法
错误原因:
urlpatterns = [
path('admin/', admin.site.urls),
path('index/', views.index),
path('cal/', views.CalPage),
path('calculate/', views.Calculate),
]
calculate路径后多了一个"/",删去即可。
修改后
urlpatterns = [
path('admin/', admin.site.urls),
path('index/', views.index),
path('cal/', views.CalPage),
path('calculate', views.Calculate),
]