Funez Camilo
Funez Camilo

Reputation: 149

How to put an object model that has a link as an attribute in a table cell in django

I am doing a simple web page using django. So i have a table that has a list of articles, each article has name, id, summary and link. The idea is to make the article name as a link when you show it up in the table:

<table class="table table-striped table-bordered table-hover table-condensed" style="font-family: Arial, Helvetica, sans-serif">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Id</th>
                    <th>Summary</th>
                                           
                </tr>
            </thead>
            <tbody>
                {% for article in articles %}
                <tr>
                    <td>{{<a href=article.link>article.name</a>}}</td>
                    <td>{{ article.Id}}</td>
                    <td>{{ article.summary}}</td>
                    <td><a href="{% url 'editArticle' article.id %}">Edit</a> <a href="{% url 'eraseArticle' article.id %}">Delete</a></td>
                    
                </tr>
                {% endfor %}
            </tbody>
        </table>

But then this error appears: Could not parse the remainder: 'article.name' from 'article.name'

Upvotes: 1

Views: 26

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476557

Using {{<a href=article.link>article.name</a>}} makes no sense, you do this with:

<a href="{{ article.link }}">{{ article.name }}</a>

Upvotes: 1

Related Questions