{"id":1359,"date":"2022-03-09T15:02:44","date_gmt":"2022-03-09T15:02:44","guid":{"rendered":"https:\/\/zerotobyte.com\/?p=1359"},"modified":"2022-03-09T15:02:45","modified_gmt":"2022-03-09T15:02:45","slug":"how-to-check-django-version","status":"publish","type":"post","link":"https:\/\/zerotobyte.com\/how-to-check-django-version\/","title":{"rendered":"How to check Django version?"},"content":{"rendered":"\n

Django is one of the most popular framework for creating web applications. Its initial release was back in 2005, and since then, more than 20 stable versions have been released. Having that many versions available to choose from, we often require methods to check our version in Django, either for deployment or dependency compatibility purposes.<\/strong> So how to check the Django version?<\/p>\n\n\n\n

Django version can be checked using multiple approaches.<\/p>\n\n\n\n

1. Using the django-admin<\/code> command line (terminal commands)<\/strong><\/p>\n\n\n\n

$ django-admin version\n4.0.3<\/pre>\n\n\n\n
$ python manage.py version\n4.0.3<\/pre>\n\n\n\n
$ python -m django version\n4.0.3<\/pre>\n\n\n\n

2. Using django<\/code> module (Python console commands)<\/strong><\/p>\n\n\n\n

>>> import django\n>>> django.VERSION\n(4, 0, 3, 'final', 0)<\/pre>\n\n\n\n
>>> import django\n>>> django.get_version()\n'4.0.3'<\/pre>\n\n\n\n

3. Using pip<\/code> (terminal commands)<\/strong><\/p>\n\n\n\n

$ pip show django\nName: Django\nVersion: 4.0.3\nSummary: A high-level Python web framework that encourages rapid development and clean, pragmatic design.\nHome-page: https:\/\/www.djangoproject.com\/\nAuthor: Django Software Foundation\nAuthor-email: foundation@djangoproject.com\nLicense: BSD-3-Clause\nLocation:...\/venv\/lib\/python3.8\/site-packages\nRequires: asgiref, backports.zoneinfo, sqlparse\nRequired-by: <\/pre>\n\n\n\n
$ pip freeze | grep Django\nDjango==4.0.3<\/pre>\n\n\n\n

4. Using pkg_resources<\/code> module (Python console command)<\/strong><\/p>\n\n\n\n

>>> import pkg_resources\n>>> pkg_resources.get_distribution('django').version\n'4.0.3'<\/pre>\n\n\n\n

We divide approaches of checking Django version by:<\/p>\n\n\n\n