Top "Django-templates" questions

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

Django TemplateSyntaxError - 'staticfiles' is not a registered tag library

After upgrading to Django 3.0, I get the following TemplateSyntaxError: In template /Users/alasdair//myproject/myapp/templates/index.html, error at …

python django django-templates django-3.0
Access request in django custom template tags

My code in myapp_extras.py: from django import template register = template.Library() @register.inclusion_tag('new/userinfo.html') def …

python django django-templates django-custom-tags
Variable subtraction in django templates

It is able to write {{ myval.add:5 }}, {{ myval|add:value }} and even {{ myval|add:-5 }}. However, I can't find out …

django django-templates
Django template escaping

Django templating system provides a few options (filters) for escaping contents in the html, but they are kind of confusing …

django django-templates django-template-filters
How to get form field's id in Django?

Is there any way to get the id of a field in a template? In the HTML I get: <…

django django-forms django-templates
How to access the user profile in a Django template?

I'm storing some additional per-user information using the AUTH_PROFILE_MODULE. We can access the user in a Django template …

python django django-templates
Change the width of form elements created with ModelForm in Django

How can I change the width of a textarea form element if I used ModelForm to create it? Here is …

python html django django-forms django-templates
django template display item value or empty string

My code in template is like this: {% for item in items %} {{ item.somefield }} {% endfor %} I want to display the item …

python django django-templates
How do I check for last loop iteration in Django template?

I have a basic question, in the Django template language how can you tell if you are at the last …

django for-loop django-templates