Django (Python Web Framework) Tutorial

Cai Gengyang gengyangcai at gmail.com
Sat Sep 26 14:42:16 CEST 2015


So I am using Mac OS X Yosemite Version 10.10.2, going through the django tutorial : https://docs.djangoproject.com/en/1.8/intro/tutorial01/ and learning to use it. Am currently on the 2nd chapter "Creating a Project" and got a question to ask :

This is the series of steps I took to reach this point :

A) I created a folder called "Weiqi" in my home directory. (named after the game I am best at!)

B) Then I typed the command $ cd Weiqi in the "Terminal"

CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd Weiqi --- input

and got this output :

CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ --- output

C) Then I ran the following command in the Terminal : $ django-admin startproject mysite.
This created a mysite folder which appeared inside the original Weiqi folder in my home directory.
When I clicked on the mysite folder, there is a manage.py file and another mysite folder inside the original mysite folder.
When I click on the mysite folder, there are 4 files in it : __init__.py , settings.py , urls.py and wsgi.py.

D) The next chapter of the tutorial says this :
"Where should this code live?
If your background is in plain old PHP (with no use of modern frameworks), you're probably used to putting code under the Web server's document root (in a place such as /var/www). With Django, you don't do that. It's not a good idea to put any of this Python code within your Web server's document root, because it risks the possibility that people may be able to view your code over the Web. That's not good for security.
Put your code in some directory outside of the document root, such as /home/mycode."

Question : I am a little confused about the last paragraph : What exactly is a "directory outside of the document root, such as /home/mycode." and how do you "Put your code in this directory" ?

Thanks a lot !

Appreciate it

Cai Gengyang


More information about the Python-list mailing list