Dude, where is my Django installation?

I use Django, but I need to find default templates and applications.

I do not know where it was installed.

How can I find this?

+75
python django installation path
Aug 12 '11 at 8:29
source share
10 answers

in the CLI you can do this:

>>> import django >>> django <module 'django' from '/usr/local/lib/python2.6/dist-packages/django/__init__.pyc'> 
+116
Aug 12 2018-11-11T00:
source share
 $ python >>> import django >>> django.__file__ '/usr/local/lib/python2.7/site-packages/django/__init__.pyc' 
+16
Aug 12 '11 at 8:30
source share

On Microsoft Microsft operating system: in the lib / site-packages folder inside your python installation.

+9
Aug 12 '11 at 8:30
source share

The current top answer does not work, at least on Linux.

From the Django tutorial :

If you find it difficult to find where the source Django files are located on your system, run the following command:

 python -c " import sys sys.path = sys.path[1:] import django print(django.__path__)" 
+7
Oct 19
source share

I describe this approach in different operating systems ...

Try this on the command line - python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

This gives you the base directory. From there, enter /django/ , and here you will find all the default templates, admin templates, etc.

Hope this helps ...

+4
Aug 12 '11 at 8:32
source share
 import django django.__file__ 

django folder location is displayed

 'C:\\Users\\saigopi\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\django\\__init__.py' 
+2
Apr 28 '17 at 5:47 on
source share

It is worth mentioning that if you use virtual env, all packages will be in your project root folder in the "lib" folder ...

0
Dec 27 '14 at 11:17
source share

If you use virtualenv, then this will be:
/ home / user / path where you installed django / django_directory / lib / python2.7 / site-packages / Django-1.8.1-py2.7. egg / django / contrib / admin / templates / admin / base_site.html
base-site.html is the default template.

0
May 23 '15 at 3:58
source share

Try this on the terminal.

 $ python -v import django # directory /home/user/.virtualenvs/myenv/local/lib/python2.7/site-packages/django # some other imports. 
0
Mar 02 '17 at 16:10
source share

As follows from the comments on @olafure https://stackoverflow.com/a/1676464/... , sys.path not required.

enough:

 $ python -c " $ import django $ print(django.__path__)" 

here the -c option is used to tell python that "the program is passed as a string" (source: command $ python --help on bash )

0
Aug 05 '17 at 15:19
source share



All Articles