Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:12:59+00:00 2026-05-23T06:12:59+00:00

What is the simplest way to create a Django template tag which displays the

  • 0

What is the simplest way to create a Django template tag which displays the Django version on a template?

I want to put the following in a Django template and have it output the Django version (in my case, base.html):

{{ django_version }}

I know that the following Python code outputs the Django version in a shell, but am confused about where I should put this code and how I should call it from the template:

import django
print django.VERSION

UPDATE: I have tried the following in views.py, but nothing shows up 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} )
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:13:00+00:00Added an answer on May 23, 2026 at 6:13 am

    Figured this out (currently using Django 1.3) — I needed to append the function name ‘django_version’ to the TEMPLATE_CONTEXT_PROCESSORS tuple in settings.py:

    TEMPLATE_CONTEXT_PROCESSORS = (  
        # ...  
        'myproject.context_processors.django_version',  
    )
    

    context_processors.py (thanks to zsquare):

    import django
    def django_version(request):
        return { 'django_version': django.VERSION }
    

    urls.py:

    urlpatterns += patterns('django.views.generic.simple',
        (r'^$', 'direct_to_template', {'template': 'base.html'}),
    )
    

    Put the following in your templates, such as base.html:

    {{ django_version }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the simplest way to create an <a> tag that links to the
Would the simplest way to create a threadpool (or, at least obtain the code
What's the simplest/canonical way to create an empty file in C#/.NET? The simplest way
What is the simplest way to dynamically create a hidden input form field using
What's the simplest way to create and write to a (text) file in Java
what is the best and most simplest way to create tooltip text for textboxes
I am trying my hardest to find the simplest way to create a basic
What is the simplest way to create my own FTP server in C#? Some
I need to create ellipse with OpenGL. The simplest way I found to do
What's the simplest way to create a vector of distinct refs? Using (repeat 5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.