Python URL在URL.py中可用,在Django 2中仍然获得404

Python URL在URL.py中可用,在Django 2中仍然获得404,python,django,django-urls,Python,Django,Django Urls,我在views.py中编写了一个函数,如下所示 def removeinvoices(请求、发票ID、创建者ID、委托人ID、更改类型): 表单=发票存储表单() form.invoiceid=invoiceid form.creatorid=creatorid form.deletorid=deletorid form.typeofchange=更改类型 form.save() thatInvoice=taxInvoice.objects.filter(invoiceid=invoiceid.

我在
views.py
中编写了一个函数,如下所示

def removeinvoices(请求、发票ID、创建者ID、委托人ID、更改类型):
表单=发票存储表单()
form.invoiceid=invoiceid
form.creatorid=creatorid
form.deletorid=deletorid
form.typeofchange=更改类型
form.save()
thatInvoice=taxInvoice.objects.filter(invoiceid=invoiceid.first())
删除()
messages.success(请求,“发票ID”+发票ID+“已成功删除!”)
返回重定向(“查看文件”)
并在
url.py
中写入如下内容:

path("removeinvoices/<int:invoiceID>/<int:creatorID/><int:deletorid>/<str:typeofchange>", views.removeinvoices, name="removeinvoices",)
路径(“removeinvoices//”,views.removeinvoices,name=“removeinvoices”,) 我在JS中动态地生成href,我能够准确地获取所有变量,但当我点击href时仍然会显示404错误

我能够很好地处理图片中提到的所有其他URL


不知道我哪里出错了

要在
Path
中使用
str
,您可以使用

url.py使用
re\u path()

至:

path("removeinvoices/<int:invoiceID>/<int:creatorID/><int:deletorid>/<str:typeofchange>", views.removeinvoices, name="removeinvoices",)
path("removeinvoices/<int:invoiceID>/<int:creatorID>/<int:deletorid>/<str:typeofchange>", views.removeinvoices, name="removeinvoices",)
path(“removeinvoices///”,views.removeinvoices,name=“removeinvoices”,)

我想您在链接中遇到了问题。如我所见,您有/removeinvoices/5/1/1/“delete”/。检查参数,url“delete”/看起来很奇怪。/removeinvoices/5/1/1/delete-也尝试了此操作:POf课程您将遇到问题,因为浏览器无法理解“delete”/。Django无法理解“删除”/!=删除/。这也会引发相同的错误,但是您在
之间的
/
上放错了位置。请尝试使用
re\u path()
path("removeinvoices/<int:invoiceID>/<int:creatorID>/<int:deletorid>/<str:typeofchange>", views.removeinvoices, name="removeinvoices",)