
Put your code in some directory outside the document root, such as /home/mycode - CaiGengYang
I am going through the 2nd chapter of this Django tutorial(Creating a Project) : https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;1.8&#x2F;intro&#x2F;tutorial01&#x2F;<p>I created a folder called &quot;Weiqi&quot; in my home directory. (named after the game I am best at!)<p>Then I typed the command $ cd Weiqi in the &quot;Terminal&quot;<p>CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd Weiqi --- input<p>and got this output :<p>CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ --- output<p>Then I ran the following command in the Terminal : $ django-admin startproject mysite.<p>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.<p>When I click on the mysite folder, there are 4 files in it : __init__.py , settings.py , urls.py and wsgi.py.<p>The next chapter of the tutorial says this :
&quot;Where should this code live?<p>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 &#x2F;var&#x2F;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.<p>Put your code in some directory outside of the document root, such as &#x2F;home&#x2F;mycode.&quot;<p>I am a little confused about the last paragraph : What exactly is a &quot;directory outside of the document root, such as &#x2F;home&#x2F;mycode.&quot; and how do you &quot;Put your code in this directory&quot; ?
======
rahimnathwani
Your document root is probably /var/www

Your web server will let any visitor read the contents of that folder. If you
put your code in there, then other people could read your code. When you were
using php, this was ok, because your web server knew that it should not let
people read your php files, but instead run the file and serve the output of
the file.

With python, it's not the same. Your Python application acts as a whole.
People aren't calling specific files like
[http://www.ggg.com/manage.py](http://www.ggg.com/manage.py)

They request a page from your server. The server knows how to use a wsgi file.
The wsgi file runs your code, and tells it what the user requested. Your code
returns a response, which the web server sends back to the user.

This code can live in any folder on your server, but if you want to keep
people from seeing your code and database credentials, then it should not be
in /var/www, but somewhere else. The book suggests your home folder. If you
don't know what that means, find a tutorial on basic command line or basic
Linux.

Good luck.

~~~
CaiGengYang
Ok, pretty sure I know what the home folder is on the Mac. Basically you click
on Finder --> Go --> Home , which takes you to the "home folder". Correct me
if I am wrong.

As for the next chapter(Database setup), I opened up mysite/settings.py as per
the instructions on the manual.

However, when I try to run the following command : $ python manage.py migrate
to create the tables in the database, I get the following error message ---

CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate ----
input

/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
can't open file 'manage.py': [Errno 2] No such file or directory ---- output

Any idea how to solve this ?

