0
我試圖捕捉兩個參數,但我不知道如何通過html發送它們。Django多個html參數
這是urls.py:
app_name = 'series'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^(?P<serie_id>[0-9]+)/$', views.season, name='season'),
url(r'^(?P<serie_id>[0-9]+)/(?P<season_id>[0-9]+)/$', views.chapter, name='chapter'),
url(r'^login/$', views.login, name='login'),
]
這是HTML:
<ul>
{% for season in season_list %}
<li><a href="{% url 'series:chapter' season.id %}">{{ season.season_name }}</a></li>
{% endfor %}
</ul>
這是視圖:
def chapter (request, serie_id, season_id):
season = Season.objects.get(pk=season_id)
chapter_list = season.chapter_set.all()
return render(request, 'series/serie.html', {'chapter_list': chapter_list})
我有此錯誤:
Reverse for 'chapter' with arguments '(1,)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'series/(?P<serie_id>[0-9]+)/(?P<season_id>[0-9]+)/$']
我該如何解決它?根據您的urls.py
謝謝,我不知道我可以傳遞這樣的多個參數。 – Lechucico
@Lechucico,如果這個答案解決了你的問題,你能否把它標記爲正確的? – chachan
我打算這樣做,但出現一條消息:「你必須等待2個小時才能回答」。 – Lechucico