Viktor Zagoruyko
Viktor Zagoruyko

Reputation: 1

Django, variable {{ }} inside {% %}

I'm using Django-instagram for simply display Instagram content on my webpage:

{% load instagram_client %}
{% instagram_user_recent_media intel %}

This example works perfect, but the problem is Instagram name changes depending on selected page. I pass it via context:

def about(request, foo_id):
    article = get_object_or_404(Bar, id=foo_id)
    return render_to_response('about.html', {'foo' : article})

It works fine if I'm using it without template:

<p>{{ foo.instagram }}</p> --> returns valid name

How can I pass my "foo.instagram" like this:

{% load instagram_client %}
{% instagram_user_recent_media {{ foo.instagram }} %}

Upvotes: 0

Views: 415

Answers (1)

RaminNietzsche
RaminNietzsche

Reputation: 2791

You can use set:

{% set new_var = foo.instagram -%}
{% load instagram_client %}
{% instagram_user_recent_media new_var %}

Upvotes: 2

Related Questions