Forums

where is the django source code?

Hey, I'm a noob here.. I'm going through the "write your first django web app." Anyway, at one point it tells me to copy/paste "admin/base_site.html from within the default Django admin template directory in the source code of Django itself..."

I was able to copy the file from the django GitHub page, but I couldn't figure out where the Django source is on my PA file system.

thanks.

You can use the python __file__ attribute to find out about where in the filesystem things are:

$ python -c "import django; print django.__file__"
/usr/local/lib/python2.7/dist-packages/django/__init__.pyc

I wrote a little tool called "pwhich" that does just that, you can install it with pip install --user pwhich, and then do pwhich.py django. I find myself doing

vi `pwhich.py django`

quite often...

It seems the syntax for this has changed in python3. Suggestions on how to do the above in python3?

In the iPython shell:

import django
django?

Gives me the info I needed.