How to Display Django version numbers in template

by Emmanuel D. on November 10, 2010

If you are using a template in Django and you want to show what version of Django you are using in your website, like the new Django 1.3, you can use this code:

In the ile

add this code:
import sys

import django

def DjangoVersionContextProcessor(request):

    one, two, three, four, five = django.VERSION

    return {“DJANGO_VERSION”: “%s.%s.%s” % (one, two, three)}

def PythonVersionContextProcessor(request):

    one, two, three, four, five = sys.version_info

    return {“PYTHON_VERSION”: “%s.%s.%s” % (one, two, three)}

After that, add this code in


    … others values in tuple removed  …


then add also this:

<a href=”” title=”Python {{ PYTHON_VERSION }}”>Python {{ PYTHON_VERSION }}</a>
<a href=”” title=”Django {{ DJANGO_VERSION }}”>Django {{ DJANGO_VERSION }}</a>

Here is a sample output:

Previous post:

Next post:

About |  Contact |  Sitemap |  Terms of Service |  Privacy