V
V
Vladimir2022-02-28 21:37:08
Django
Vladimir, 2022-02-28 21:37:08

How to loop with url in django and jinja?

In the application, in the urls.py file, I have app_name='women'
How can I display links to the desired name in the loop, since I wrote an error:

Reverse for 'm.url_name' not found. 'm.url_name' is not a valid view function or pattern name.

{% for m in menu %}
  {% if not forloop.last %}
      <li><a href="{% url 'women:m.url_name' %}">{{m.title}}</a></li>
  {% else %}
      <li class="last"><a href="{% url 'women:m.url_name' %}">{{m.title}}</a></li>
{% endif %}
{% endfor %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-03-01
@bacon

ok google, "django jinja url"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question