Questions tagged [django-templates]

Questions about the template engine of Django, which is intended to separate the presentation of a document from its data.

A Django template is a string of text that is intended to separate the presentation of a document from its data. A template defines placeholders and various bits of basic logic — tags — that regulate how the document should be displayed. Usually, templates are used for outputting HTML but Django templates are equally capable of generating any text-based format.

The two key features of Django templates are that they are not, on their own, very powerful (in particular, no functions may be called with parameters), and a flexible, extensible tag system which allows users to break out of its constraints. This tends to prevent logic other than presentation logic from creeping into templates.

An example template built with the Django template language.

<html>
    <head>
        <title>{{ site.title }}</title>
    </head>
    <body>
        <h1>{{ site.greeting }}</h1>
        <ul>
            {% for item in menu_items %}
            <li>{{ item|upper }}</li>
            {% endfor %}
        </ul>
    </body>
</html>

See the official documentation for more details.

19491 questions
4
votes
0 answers

Django template tag requires js/css

We created a template tag which adds a button that opens a dialog (to display additional information). The dialog needs an extra js file and one css file. At the moment, both, the js and the css file is added as global requirement in our Django…
tzanke
  • 198
  • 1
  • 12
4
votes
2 answers

Django : How to pass context?

I know about passing the context to templates, but I am bit confused with the given scenario, please help class X: id: name: status: Class Main: number1: object of X number2: object of X message: "Hello World!" I get Object of Main which has…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
4
votes
1 answer

Does Django cache custom tags and filters?

I have a considerable number of custom template tags that perform a variety of functions, including: simple string transformation display of complex ui elements timestamp manipulation and formatting handling and display of user avatars etc... All…
tino
  • 4,780
  • 5
  • 24
  • 30
4
votes
5 answers

How to correctly pre-populate textarea in django?

I have this rather annoying problem: In the template I have
{{ form.aboutme.errors }}