What is the easiest way to create a Django template tag that displays the version of Django in the template?
I want to put the following in a Django template and release a version of Django (in my case, base.html):
{{ django_version }}
I know that the following Python code outputs a version of Django in a shell, but I'm confused about where I should put this code and how I should call it from a template:
import django
print django.VERSION
UPDATE: I tried the following in views.py but nothing is displayed in the template:
import django
from django.template import loader, Context
from django.http import HttpResponse
from django.shortcuts import render_to_response
def base(request):
django_version = django.VERSION
return render_to_response('base.html', {'django_version': django_version} )
source
share