使用传递的参数时,我总是报告一个错误,但是如果更改此
{%网址
,此错误将消失。请帮助我解决问题。
views.py 是:
def mmmm(request):
return render(request, 'test3.html')
def gettime(request, year, day, month):
return HttpResponse("time is %s-%s-%s" % (year, month, day))
urls.py 是:
app_name = "four"
urlpatterns = [
re_path(r'mmmm', views.mmmm, name='mmmm'),
re_path(r'gettime/(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/$', views.gettime, name='gettime'),
]
test2.html是:
<a href="{% url 'mmmm' %}">mmmmm</a><br>
<a href="{% url 'gettime' year=2019 month=12 day=18 %}">cmdb/userinfo/tom/tomnickname/10</a><br>
此错误是:
Error during template rendering
In template /Users/jumporange/PycharmProjects/HelloDjango/templates/test2.html, error at line 15
'set' object is not reversible
5 <title>Get student</title>
6 </head>
7 <body>
8 <ul>{% for student in students %}
9 <li>{{ student.s_name }}</li>
10 {% endfor %}
11 </ul>
12 {#<a href="/FOUR/index">mmm</a>#}
13
14 {#<a href="{% url 'mmmm' %}">mmmmm</a><br>#}
15 <a href="{% url 'gettime' year=2019 month=12 day=18 %}">cmdb/userinfo/tom/tomnickname/10</a><br>
16 </body>
17 </html>