0
형식 오류 : 음악 /에서형식 오류 장고
형식 오류/1/
세부 사항() 예기치 않은 키워드 인수 'PK'
있어요청 방법 : GET 요청 URL : http://127.0.0.1:8000/music/1/ 예외 유형 : TypeError
: 0 세부 사항() 예기치 않은 키워드 인수 'PK'이 내 음악 \의 view.detail 기능
def detail(request, album_id):
album = get_object_or_404(Album, pk=album_id)
return render(request, 'music/detail.html', {'album':album})
이며,이 오류를 올릴 수있는 내 detail.html의 형태를 가지고
<form action="{% url 'music:favorite' album.id %}" method="post">
{% csrf_token %}
{% for song in album.song_set.all %}
<!-- forloop.counter indicates how many times the for tag has gone
through its loop -->
<input type="radio" id="song{{ forloop.counter }}" name="song"
value="{{ song.id }}"/>
<label for="song{{ forloop.counter }}">
{{ song.song_title }}
{% if song.is_favorite %}
<img src="http://i.imgur.com/b9b13Rd.png" />
{% endif %}
</label><br>
{% endfor %}
<input type="submit" value="Favorite">
</form>
그리고 이것은 내 urls.py
당신의 패턴에서from django.conf.urls import url
from . import views
app_name = 'music'
urlpatterns = [
# /music/
url(r'^$', views.index, name = 'index'),
# /music/<album_id>/
url(r'^(?P<pk>[0-9]+)/$', views.detail, name = 'detail'),
# /music/<album_id>/favorite
url(r'^(?P<album_id>[0-9]+)/favorite/$', views.favorite, name =
'favorite'),
]
'urls.py' 파일이란 무엇입니까? –
위에 추가했습니다. –