Python 与#x27相反;最爱';带参数';(';';,)';未找到,跟随Bucky';YouTube上的s Django教程
我一直在/music/2/error上找到NoReverseMatch,它指向我从中继承的父模板base.html,但我找不到任何错误。我知道当有人要求你搜索错误时,这可能很烦人,但也许有人可以很容易地看到我看不到的东西Python 与#x27相反;最爱';带参数';(';';,)';未找到,跟随Bucky';YouTube上的s Django教程,python,django,django-templates,Python,Django,Django Templates,我一直在/music/2/error上找到NoReverseMatch,它指向我从中继承的父模板base.html,但我找不到任何错误。我知道当有人要求你搜索错误时,这可能很烦人,但也许有人可以很容易地看到我看不到的东西 {% extends "music/base.html" %} {% block content %} <p> Album : {{one_album}} </p> <p> Song list : </p> {% if somet
{% extends "music/base.html" %}
{% block content %}
<p> Album : {{one_album}} </p>
<p> Song list : </p>
{% if somethings_wrong %}
<p> {{ somethings_wrong }} </p>
{% endif %}
<form action = "{% url 'music:favorite' album.id %}" method="post" >
{% csrf_token %}
{% for song in album_entries %}
<input type="radio" id="song{{forloop.counter}}" name="song" value="{{ song.id }}">
<label for="song{{ forloop.counter }}">
{{ song.song_title }}
{% if song.is_favorite %} #afterwards, set this explicitly to true, for learning purposes
<img src="https://i.imgur.com/olM72b8.png"/> #check if this slash is necessary later
{% endif %}
</label><br>
{% endfor %}
<input type="submit" value="Favorite">
</form>
{% endblock content %}
我认为错误就在这里,url.py和models.py非常简单。我已经将is_favorite booleanfield添加到Song类中,默认情况下为False,而url.py非常简单
path('<int:album_id>/favorite', views.favorite, name='favorite')
path('/favorite',views.favorite,name='favorite')
要引用的变量是one\u相册
但你称之为相册。
改变
<form action = "{% url 'music:favorite' album.id %}" method="post" >
到
要引用的变量是one\u相册 但你称之为相册。 改变
<form action = "{% url 'music:favorite' album.id %}" method="post" >
到
完成,单击swoosh标志。我不知道我应该:)完成了,点击了swoosh标志。我不知道我应该:)
<form action = "{% url 'music:favorite' album.id %}" method="post" >
<form action = "{% url 'music:favorite' one_album.id %}" method="post" >