gpt4 book ai didi

python - 如何修复django模板中的html代码

转载 作者:太空宇宙 更新时间:2023-11-03 20:13:18 24 4
gpt4 key购买 nike

这是现在的模板错误。

   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

我认为是指定的路径不正确,我不知道如何处理这个错误。未找到“product_detail”的反向操作。 “product_detail”不是有效的 View 函数或模式名称。

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>

我不知道如何解决这个错误,请帮忙,提前致谢。

最佳答案

检查第 27 行

<img src=" {% if product.image %}{{ product.image.url }}{% else %}{% state}" /> 

应该是

<img src=" {% if product.image %}{{ product.image.url }}{% else %}{state}{% endif %}" />

关于python - 如何修复django模板中的html代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58602278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com