简体   繁体   中英

Django URL with parameters not working

I'm trying to use pass a parameter to a URL in Django, but I keep getting this error:

 Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/%7B%25%20url%20review%20review_id%3D3%20%25%7D
Using the URLconf defined in soundclinic.urls, Django tried these URL patterns, in this order:

[name='index']
login/ [name='login']
register/ [name='register']
create_user [name='create_user']
<int:review_id>/review/ [name='review']
admin/
main/
The current path, {% url review review_id=3 %}, didn't match any of these.

The link I am follow has a tag like above: {% url review review_id=3 %}

I'm not sure what I'm not including right, as it looks like I'm writing out the url tag correctly and urls.py seems to be configured correcely as well.

Manually entering in the URL calls the correct views.py function, so it only has to do with my urls.py file.

As kszl already said, you must use " ' " around your URL name.

{% url 'review' review_id=3 %}

It supposes you have a URL in some url.py that has the name "review". It seems to be the case though since we can see

<int:review_id>/review/ [name='review']

in your log message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM