Python Django:复合URL
我正在尝试为我的公司创建一个简单的办公室管理网站。我有一个列出员工的主模板。每个员工都是html模板中的一个链接Python Django:复合URL,python,django,url,Python,Django,Url,我正在尝试为我的公司创建一个简单的办公室管理网站。我有一个列出员工的主模板。每个员工都是html模板中的一个链接 <a href="{% url 'personnel:employee_detail' employee_id=employee.id %}">{{ employee }}</a> 以及url(从主页到员工详细信息页面: url(r'^employee-main/(?P<employee_id>\d+)/$', employee_detail,
<a href="{% url 'personnel:employee_detail' employee_id=employee.id %}">{{ employee }}</a>
以及url(从主页到员工详细信息页面:
url(r'^employee-main/(?P<employee_id>\d+)/$', employee_detail, name='employee_detail')
和404页面未找到错误。我不确定这是url中的日期错误还是因为我正在尝试复合url(2个变量)?您好,我假设您指的是第一个模板url?是的,它只是指向特定员工的链接,但我更新了问题。谢谢,我重新启动了服务器,但仍然无法工作。我再次编辑了我的问题。工资单中的员工id与员工.id完全相同。您100%确定该模板完全相同和你的问题一样?你复制并粘贴了准确的代码?我问你是因为你问题中的代码在我看来还行,我不明白为什么它会导致你看到的url。不确定两个变量是什么意思。你的url中有四个变量。
url(r'^employee-main/(?P<employee_id>\d+)/$', employee_detail, name='employee_detail')
<ul>
{% for payslip in payslips %}
{% if payslip.date = active_payslip.date %}
<li><b>{{ payslip.date|date:"Y-m-d" }}</b></li>
{% else %}
<li><a href="{% url 'personnel:employee_detail_specific' employee_id=payslip.employee_id year=payslip.date|date:'Y' month=payslip.date|date:'m' day=payslip.date|date:'d' %}">{{ payslip.date|date:"Y-m-d" }}</a></li>
url(r'^employee-main/(?P<employee_id>\d+)/(?P<year>\w+)/(?P<month>\w+)/(?P<day>\w+)/$', employee_detail, name='employee_detail_specific')
employee-main/14/%7B%%20url%20'personnel:employee_detail_specific'%20employee_id=payslip.employee_id%20year=payslip.date%7Cdate:'Y'%20month=payslip.date%7Cdate:'m'%20day=payslip.date%7Cdate:'d'%20%7D