diogenes
diogenes

Reputation: 2129

Django URL with {% URL %} from data string

I am trying to pass string information into a {% URL %}

I am getting the data from data like:

    {% for p in proj %}

      <tr>
        <td>
          <a href="{% url  {{ p.dir }} %}"> {{ p.name }} </a>
        </td>
      </tr>

    {% endfor %}

The expected result would be something like:

<a href="{% url "path" %}">Sample Info</a>

Is this even possible?

Thanks.

Upvotes: 1

Views: 27

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174662

From the documentation:

The first argument is a URL pattern name. It can be a quoted literal or any other context variable.

So you need to use {% url p.dir %}

Upvotes: 2

Related Questions