Thursday, May 2, 2019

Reverse not found problem

Hello, I'm new to django. I have faced with this problem and couldn't find an answer to my problem. I zip 2 lists and I want to iterate them simultaneously.

I get this error
Reverse for '{{newspaper}}' not found. '{{newspaper}}' is not a valid view function or pattern name.


my html file
{% extends "index-template.html" %}

{% block content %}
{% load staticfiles %}
{%
for newspaper, newspaper_name in mylist %}
<li
class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
    <div class="box nop">
        <div class="bar"> <img src="{% static "/icons/{{newspaper}}.png" %}".......
{% endfor %}
{% endblock %}




my index fuction in views.py
def index(request):
    newspapers = [
"BBC", "Guardian"]

    newspaper_names = [
"BBC News", "The Guardian"]
    mylist = zip(newspapers, newspaper_names)

   
return render(request, "index.html", {"currentdate": getcurrentdate(), "mylist": mylist})

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a80a350b-040b-4e9d-9954-44032ccc9a7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment