I am starting a new (actually very old) project which I know is in Django. I am getting lost knowing the exact version of Django it has been build upon. Is there a way I can know the version of Django my application is running?
6 Answers
The only way is to take a guess. I would start by looking at the created date of the settings.py file (or other base project files)
Release dates for versions:
Having in your urls.py:[4]
from django.conf.urls.defaults import *
from django.contrib import admin
or having an admin.py
file in an application [5] suggests that it is a 1.0+ project.
Having in your urls.py: [6]
(r'^admin/', include(admin.site.urls)),
would suggest 1.1+.
Having in your settings.py file:
DATABASES = {
'default': {
'NAME': 'app_data',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'postgres_user',
'PASSWORD': 's3krit'
},
'users': {
'NAME': 'user_data',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'priv4te'
}
}
would suggest 1.2+.
[1]: 1.1 release notes
[2]: 1.2 release notes
[3]: 1.3 release notes
[4]: Backwards Incompatible changes 0.96 > 1.0
[5]: Backwards Incompatible changes 0.96 > 1.0
[6]: Multiple databases

- 30,738
- 21
- 105
- 131

- 21,330
- 4
- 34
- 65
-
2This will tell you the *current* version of Django, not the version the project was built for. – Ignacio Vazquez-Abrams Jun 30 '11 at 05:26
-
@jJames Khoury Actually I am trying to run the project ,but getting lost which version of Django to use. It is not a running project . I mean it was a running project , now I am debugging some of the features. – Prabesh Shrestha Jun 30 '11 at 05:34
-
@prabech Then my answer will not help. In that case you'd have to look at your settings.py file nd its created date. From this you might be able to guess by the changes in recent updates. – James Khoury Jun 30 '11 at 05:36
-
1@prabesh I've update my answer and i'll keep looking for things that will tell you which version. – James Khoury Jun 30 '11 at 05:53
-
1HAHA! You just edited your answer as I was composing mine to include the database settings as a good hint!! Well played, sir! – jathanism Jun 30 '11 at 06:07
-
@jathanism I added them as quick as I could remember and find them. Its just that my brain works too slow at the end of the day ;) – James Khoury Jun 30 '11 at 06:10
You can guess based on the way settings.py is laid out. Your first hint would be from database settings. The old way prior to Django 1.2 was:
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = os.path.join(BASE_DIR, 'db') # Or path to database file if using sqlite3.
#DATABASE_USER = '' # Not used with sqlite3.
#DATABASE_PASSWORD = '' # Not used with sqlite3.
#DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
#DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
This method is still supported up to 1.3 but now causes Django to complain loudly about it being deprecated.
As of Django 1.2 the following format is used:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_DIR, 'mycms.db'),
}
}
While this isn't definitive, it does at least give you a hint to whether your app was written either before or after Django 1.2.
Keep in mind is that an app written against an older version of Django should still work, but you'll likely get a lot of deprecation warnings on the console if your code is referencing stuff that has been deprecated or just moved around.
These warnings can usually safely be ignored in the short-term but you should definitely take time to silence them by updating your code to reference the features in their new home/format. The Django devs do a good job of doing the right thing as far as giving ample time and warning for older functionality to be properly migrated as time goes by.

- 33,067
- 9
- 68
- 86
-
+1 for the depreciated Warnings. This is an excellent way to find out. – James Khoury Jun 30 '11 at 06:11
I see the answer accepted above and I think it's much easier. Maybe I'm missing something, but this is what I would do.
Open a python terminal that has the Django project on its path.
$ python
>>> import django
>>> print django.get_version()
0.97-pre-SVN-7668
That version number is strictly for illustration. Yours may differ, I hope.

- 1,532
- 14
- 17
-
4ya to get the version of django installed the one you posted is a lot easier. But that is not what I needed. I wanted to know the version of django my project was created for. – Prabesh Shrestha Jun 30 '11 at 15:23
-
1I am coming with some experience in rails and to get the version an application is using you just have to check the gemfile or with earlier version you had to check some configuration files. Actually both the answers above helped me a lot since I am new to django. Anyways thank you. – Prabesh Shrestha Jun 30 '11 at 15:25
-
2or you could just do `django-admin.py --version` to get the version of the currently installed django version – Succeed Stha Jul 04 '11 at 06:30
This works in Django 1.7:
import django
django.VERSION
...which yields (on my machine):
(1, 7, 0, 'rc', 3)
Note: It's important that you need to make sure you are running inside a python virtual environment before running this, as otherwise you'd importing the system wide django, not at the project level.
-
Would the downvoter care to add a comment as to why this was downvoted? A similar answer is top voted here: http://stackoverflow.com/questions/6468397/how-to-check-django-version – Patrick Feb 23 '15 at 15:53
-
1wouldn't this only tell you the version that was installed and not the version that the app depends on? – Ramy Aug 02 '16 at 20:01
https://docs.djangoproject.com/en/1.7/intro/tutorial01/:
python -c "import django; print(django.get_version())"
which gets me the following:
1.7.1

- 762
- 1
- 11
- 24
-
2wouldn't this only tell you the version that was installed and not the version that the app depends on? – Ramy Aug 02 '16 at 20:01
Django settings for ********** project.
Generated by 'django-admin startproject' using Django 2.0.9.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
when you open your settings.py
file you can see the django version above.

- 27,428
- 11
- 44
- 69

- 23
- 4