Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97140 > unrolled thread

Django (Python Web Framework) Tutorial

Started byCai Gengyang <gengyangcai@gmail.com>
First post2015-09-26 05:42 -0700
Last post2015-09-26 21:12 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Django (Python Web Framework) Tutorial Cai Gengyang <gengyangcai@gmail.com> - 2015-09-26 05:42 -0700
    Re: Django (Python Web Framework) Tutorial John Gordon <gordon@panix.com> - 2015-09-27 03:45 +0000
      Re: Django (Python Web Framework) Tutorial Cai Gengyang <gengyangcai@gmail.com> - 2015-09-26 21:12 -0700

#97140 — Django (Python Web Framework) Tutorial

FromCai Gengyang <gengyangcai@gmail.com>
Date2015-09-26 05:42 -0700
SubjectDjango (Python Web Framework) Tutorial
Message-ID<1421a34f-d8cc-4367-adab-2c2b46504d72@googlegroups.com>
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

[toc] | [next] | [standalone]


#97150

FromJohn Gordon <gordon@panix.com>
Date2015-09-27 03:45 +0000
Message-ID<mu7opg$ntt$1@reader1.panix.com>
In reply to#97140
In <1421a34f-d8cc-4367-adab-2c2b46504d72@googlegroups.com> Cai Gengyang <gengyangcai@gmail.com> writes:

> 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" ?

Django is a web application framework.  So, you have to use it together with
a web server.  The "document root" is the directory where the web server
expects to find files to be served as web pages.

You said you put the Django project code in a subdirectory of your home
directory.  That should be fine.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#97151

FromCai Gengyang <gengyangcai@gmail.com>
Date2015-09-26 21:12 -0700
Message-ID<2835a1b1-e5f7-4ff7-b318-c0ebdd0f6d98@googlegroups.com>
In reply to#97150
On Sunday, September 27, 2015 at 11:46:13 AM UTC+8, John Gordon wrote:
> In <1421a34f-d8cc-4367-adab-2c2b46504d72@googlegroups.com> Cai Gengyang <gengyangcai@gmail.com> writes:
> 
> > 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" ?
> 
> Django is a web application framework.  So, you have to use it together with
> a web server.  The "document root" is the directory where the web server
> expects to find files to be served as web pages.
> 
> You said you put the Django project code in a subdirectory of your home
> directory.  That should be fine.
> 
> -- 
> John Gordon                   A is for Amy, who fell down the stairs
> gordon@panix.com              B is for Basil, assaulted by bears
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"


Ok.

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

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

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

I get the following error message :

/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 issue?

Thanks a lot !

Gengyang

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web