1

For my project, I'm searching for articles on google news based on keyword input by the user, I want to display these links obtained from the search on my results page.

this is my result.html

{% extends 'base.html' %}

{% block title %}Result{% endblock %}

{% block content %}

    <h3><a href="{{link_to_post}}" target="_blank">Reported Url</a></h3>
    <div>Post Content: <br>{{content}}</div>

    <h3>News articles related to your query:</h3>
    <ul>
    {% for key, value  in articles.items %}

    <li><a href="{{key}}">{{value}}</a></li>

    {% endfor %}
    </ul>

    <div>
        <a href="{% url 'home' %}">Back to Home Page</a>
    </div>

{% endblock %}

But the links do not work and I get the page not found error, since these links are not contained in urls.py. How can I link these urls correctly?

thank you

Karmah24
  • 485
  • 1
  • 5
  • 14

2 Answers2

1

You cannot execute python code inside Django templates. Check out this thread: Numeric for loop in Django templates

0

Fixed the problem I had to replace "./" in the article to the homepage of the site I was refering to.

Karmah24
  • 485
  • 1
  • 5
  • 14