You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have read through the Django Tutorial, you've seen examples for templating in Django. While the rest of Django, such as models, settings, migrations, etc., is the same (with or without DMP), the way you do templates will obviously change with DMP. The following examples should help you understand the different between standard Django and DMP template syntax.
Note in the examples how the DMP column normally uses standard Python syntax, with no extra language to learn:
Output the value of the question variable:
Django Templates
DMP (Mako) Templates
{{ question }}
${ question }
- Output a user's full name (a method on User):
Django Templates
DMP (Mako) Templates
{{ user.get_full_name }}
${ user.get_full_name() }
- Iterate through a relationship:
Django Templates
DMP (Mako) Templates
<ul>
{% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }}</li>
{% endfor %}
</ul>
<ul>
%for choice in question.choice_set.all():
<li>${ choice.choice_text }</li>
%endfor
</ul>