Reputation: 156
I want to see the django version in my Pycharm terminal, but I don't get the correct method.
I tried bellow methods in pycharm terminal:
1) django --version
and django version
2) import django, and print the version by:
import django
print django.VERSION
But I still can not get it.
Upvotes: 1
Views: 8278
Reputation: 416
Using the following command on terminal will give you django version
python -m django --version
Or You can go to the interactive python prompt and use the command
import django
print(django.get_version())
or using pip freeze and grep you can also get the django version
pip freeze | grep Django
Upvotes: 0
Reputation: 5
I had the same question. The solution is simple. Just create a project, open settings.py file and observe the first comment lines. You will see the version info in there as displayed below:
Image of settings.py that shows the Django version
I found the solution here.
Upvotes: 0
Reputation: 1
I do not know about pychram but the most efficient way to query the django version without importing django globally would be this:
from django import VERSION as DJANGO_VERSION
if DJANGO_VERSION >= (2, 0):
pass
What was not proposed in this question which is something similar: How to check Django version
Upvotes: 0
Reputation: 3
Run pip freeze > requirements.txt
A .txt file with that name will be created automatically, open the file and check for the django version and other previously installed libraries.
Upvotes: 0
Reputation: 95
go to setting > project > project Interpreter and install Django package then run the code
import django
print(django.get_version())
Upvotes: 0
Reputation: 1066
You can run pip freeze too. Just filtering the results with grep...
pip freeze | grep Django
Upvotes: 1
Reputation: 374
If you cannot print the Django version from the python console in Pycharm, go to settings>Project:project_name>project Interpreter and from the list of installed packages see the installed Django and it's version for that project.
Upvotes: 2
Reputation: 26876
In the terminal you can use bellow command to check the version of django:
python -m django --version
If you want to use your second method, just like this bellow command:
python -c "import django; print(django.VERSION)"
(1, 11, 2, u'final', 0)
Upvotes: 0
Reputation: 429
You're trying to access a version attribute, but you can find out Django's version using the get_version
method:
import django
django.get_version()
Upvotes: 0