[英]How to fix the html code in django template
This is the template error right now.这是现在的模板错误。
NoReverseMatch at /
Reverse for 'product_detail' not found. 'product_detail' is not a valid view function or pattern name.
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.2.6
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'product_detail' not found. 'product_detail' is not a valid view function or pattern name.
Exception Location: C:\Users\Others\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 673
Python Executable: C:\Users\Others\AppData\Local\Programs\Python\Python38\python.exe
Python Version: 3.8.0
Python Path:
['C:\\reet\\mysite\\myshopping',
'C:\\Users\\Others\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
'C:\\Users\\Others\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
'C:\\Users\\Others\\AppData\\Local\\Programs\\Python\\Python38\\lib',
'C:\\Users\\Others\\AppData\\Local\\Programs\\Python\\Python38',
'C:\\Users\\Others\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages']
Server time: Tue, 29 Oct 2019 07:01:37 +0000
Error during template rendering
In template C:\reet\mysite\myshopping\shop\templates\shop\base.html, error at line 0
I think it's the path specified is incorrect,I not sure how to deal with this error.我认为是指定的路径不正确,我不知道如何处理这个错误。 Reverse for 'product_detail' not found.未找到“product_detail”的反向。 'product_detail' is not a valid view function or pattern name. “product_detail”不是有效的视图 function 或模式名称。
1
2 {% load static %}
3 <!DOCTYPE html>
4 <html>
5 <head>
6 <meta charset="utf-8" />
7 <title>{% block title %}My shop{% endblock %}</title>
8 <link href="{% static "css/base.css" %}" rel="stylesheet">
9 </head>
10 <body>
I'm not sure how to figure this error,please do help,thanks in advance.我不知道如何计算这个错误,请帮忙,在此先感谢。
check this line 27检查这一行 27
<img src=" {% if product.image %}{{ product.image.url }}{% else %}{% state}" />
it should be它应该是
<img src=" {% if product.image %}{{ product.image.url }}{% else %}{state}{% endif %}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.