Thursday, February 28, 2013

Re: Use variable in my template?

On Thu, Feb 28, 2013 at 2:40 PM, Maria <mariahenkel@gmx.de> wrote:
> No I dont have a problem to find the images, i already used a variable to
> insert images from the static folder. Its just that I cant use my "marke"
> variable because it is in an external .py file and I would like to learn how
> to use that external variable in my template.
>

Put the variable in the context that you use to render the template.
The variables available in your template are the variables in the
context you supply when rendering your template.

All the template rendering functions take both a Context object and a
raw dictionary. The Context object is created if none is supplied, and
updated with the values in the dictionary (and any template context
processors if using a RequestContext). Eg for the render() shortcut:

https://docs.djangoproject.com/en/1.4/topics/http/shortcuts/#render

If it is still clear, this concept is explained further in the tutorial.

Cheers

Tom

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment