错误信息:Reverse for 'org_detail' with no arguments not found. 1 pattern(s) tried: ['orgs/org_detail/(d+)/$']
views.py
def org_detail(request, org_id):
if org_id:
org = OrgInfo.objects.filter(id=int(org_id))[0]
return render(request, 'orgs/org-detail-homepage.html', {
'org': org
})
org-list.html
{% url 'orgs:org_detail' org.id %}
{% for org in pages %}
<dl class="des difdes">
<dt>
<a href="{% url 'orgs:org_detail' org.id %}">
<img width="200" height="120" class="scrollLoading"
data-url="{{ MEDIA_URL }}{{ org.image }}"/>
</a>
</dt>
<dd>
<div class="clearfix">
<a href="{% url 'orgs:org_detail' org.id %}">
<h1>{{ org.name }}</h1>
<div class="pic fl">
<img src="{% static 'images/authentication.png' %}"/>
<img src="{% static 'images/gold.png' %}"/>
</div>
</a>
</div>
<ul class="cont">
<li class="first"><p class="pic9">课程数:<span>{{ org.course_num }}</span></p>
<p class="c7">学习人数:<span>{{ org.study_num }}</span></p></li>
<li class="c8" style="padding-left:18px;">{{ org.address }}</li>
<li class="pic10" style="padding-left:18px;">经典课程:
{% for course in org.courseinfo_set.all|slice:":2" %}
<a href="/diary/19/">{{ course.name }}</a>
{% endfor %}
</li>
</ul>
</dd>
<div class="buy start_groupbuy jsShowPerfect2" data-id="22"><br/>联系<br/>服务</div>
</dl>
{% endfor %}
urls.py
from django.urls import path, re_path
from orgs import views
app_name = 'orgs'
urlpatterns = [
re_path('org_list/$', views.org_list, name='org_list'),
re_path('org_detail/(d+)/$', views.org_detail, name='org_detail'),
]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…