Python url.py可以工作,但当我使用<;内部:id>;若要更新特定项目,则我会得到;当前路径没有';“我不匹配这些中的任何一个”;错误

Python url.py可以工作,但当我使用<;内部:id>;若要更新特定项目,则我会得到;当前路径没有';“我不匹配这些中的任何一个”;错误,python,django,django-models,crud,django-urls,Python,Django,Django Models,Crud,Django Urls,My urls.py在尝试读取或创建新项目时起作用。但在尝试更新现有项目时,我会执行以下操作: 在app/url.py中: ... path('update_goals/<int:id>', update_goals, name='update_goals'), 在models.py中: class Items(models.Model): id = models.AutoField(db_column='ID', primary_key=True) company

My urls.py在尝试读取或创建新项目时起作用。但在尝试更新现有项目时,我会执行以下操作: 在app/url.py中:

...
path('update_goals/<int:id>', update_goals, name='update_goals'),
在models.py中:

class Items(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)
    company = models.CharField(null=True, db_column='Company', max_length=40, blank=True)  # Field name made lowercase.
    ...
    class Meta:
        managed = False
        db_table = 'Items'
        verbose_name_plural = 'Items'
html:

{item%]中的i的%
{%endfor%}
我用来读取当前项目和创建新项目的其他路径也可以工作,但只是更新不起作用

错误:

Page Not Found(404)
Request URL:    http://127.0.0.1:8000/%7Burl%20'update_goals%20i.id'%7D
Using the URLconf defined in app1.urls, Django tried these URL patterns, in this order:

...
update_goals/<int:id> [name='update_goals']
admin/
The current path, {url 'update_goals i.id'}, didn't match any of these.

未找到页面(404) 请求URL:http://127.0.0.1:8000/%7Burl%20'更新目标%20i.id“%7D” Django使用app1.URL中定义的URLconf,按以下顺序尝试了这些URL模式: ... 更新_目标/[name='update_目标'] 管理员/ 当前路径{url'update_goals i.id'}与这些路径都不匹配。 它可能与ID列有关,但我也尝试使用了
update\u goals/
abd
I.company
,但仍然会出现相同的错误。

\35;您只需更改html文件内容中的url即可
# You just need to change url in html file content

{% for i in item %}
<a href="{% url 'update_goals' id=i.id %}">
        <li>{{i.company}}</li>
        ...
</a>
{% endfor %}
{项目%中的i为%1} {%endfor%}
这不是Django模板标记的正确语法。@DanielRoseman,否则我怎么做?它不起作用。。我收到了相同的错误:请求URL:当前路径{URL'update_goals id=I.id'}与以下任何路径都不匹配。。请试试这个,我刚刚编辑了我的答案。我错过了%before}。
Page Not Found(404)
Request URL:    http://127.0.0.1:8000/%7Burl%20'update_goals%20i.id'%7D
Using the URLconf defined in app1.urls, Django tried these URL patterns, in this order:

...
update_goals/<int:id> [name='update_goals']
admin/
The current path, {url 'update_goals i.id'}, didn't match any of these.

# You just need to change url in html file content

{% for i in item %}
<a href="{% url 'update_goals' id=i.id %}">
        <li>{{i.company}}</li>
        ...
</a>
{% endfor %}