Thursday, February 28, 2013

Re: Use variable in my template?

Can you tell me where exactly to insert that Variable?

def detail(request, poll_id):
    p = get_object_or_404(Poll, pk=poll_id)
    return render_to_response('polls/detail.html', {'poll': p},

Also, do I have to create a class "marke"? Because up until now I only have:

from choice import*

global marke
marke = read_m()

This variable reads an image name. I want to use it for {{ marke }}.jpg

On Thursday, February 28, 2013 12:06:02 PM UTC+1, Maria wrote:
Hello everyone,
I have a variable I want to have access to in my Django template. But somehow I can't manage to do that.
I got Django/mytemplates/polls/detail.html (template) where I want to insert an image:

{% load staticfiles %}

<link href="{% static "style.css" %}" rel="stylesheet" type="text/css" media="screen" />

 <img src="{{ STATIC_URL }}images/{{ marke.marke }}.jpg" alt="Picture" />
Django/mysite/polls/ :

from choice import*

global marke
marke = read_m()

The value of marke is marke3 and I have an image marke3.jpg. I successfully used another variable to insert an image ( but this time it wont work.
The folder 'polls' is in my INSTALLED_APPS.
What can I do?

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
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment