Ошибка обратного хода Django при передаче дополнительной переменной
Я пытаюсь передать переменные через различные представления django.
Ошибка, которую я получаю:
Reverse for 'download_file' with keyword arguments '{'path_id': '19', 'filename': 'TESTCE-DCNCE-01.conf'}' not found. 1 pattern(s) tried: ['download/(?P<filename>[^/]+)/\\Z']
У меня есть следующий рабочий код:
Это мой view.py
def report(request, pk_test):
order = Order.objects.get(id=pk_test)
path_id = str(order.id)
outpath = 'orchestration/outputs/' + str(order.id)
files_configs = glob.glob(outpath + '/*.conf', recursive=True)
files = []
for each_file in files_configs:
head, tail = path.split(each_file)
files.append(tail)
context = {
'order': order,
'files_configs': files,
'path_id': path_id,
}
return render(request, 'orchestration/report.html', context)
Вот мой отчет.html:
{% for each_files_configs in files_configs %}
<p></p>
<a href="{% url 'download_file' filename=each_files_configs %}">{{ each_files_configs }}</a>
{% endfor %}
Это мой views.py, который связан с href:
def download_file(request, filename=''):
if filename != '':
Когда я запускаю код, как показано ниже, он работает нормально. Если я добавляю дополнительный параметр 'path_id', как показано ниже, я получаю обратную ошибку. Конечно, path_id не отличается от передачи имени файла?
{% for each_files_configs in files_configs %}
<p></p>
<a href="{% url 'download_file' path_id=path_id filename=each_files_configs %}">{{ each_files_configs }}</a>
{% endfor %}
Это мой views.py, который связан с href:
def download_file(request, path_id='', filename=''):
if filename != '':