linux, create a web site

1.Enable and disable python

    Enable:

$ python  

    quit:

$ exit()

 2.linux: operation command summary

Command (Windows) Command (Mac OS / Linux) Description: Example:
exit exit close the window exit
cd cd   zzz            cd test
to you ls List of directory files to you
copy cp copy file copy c:\test\test.txt c:\windows\test.txt
move mv move files move c:\test\test.txt c:\windows\test.txt
mkdir mkdir Create a new directory mkdir testdirectory
the rm delete text file directory del c:\test\test.txt

3. Virtual environment:

          Virtual environments isolate your Python/Django installation on a project-by-project basis. This means that changes to one website will not affect any other website you are developing at the same time.

     Call the virtual environment: myvenv,. The general command format is:

python3 -m venv myvenv

 4. Create a web site!

(1). Create a new Django project;

django-admin startproject mysite .

Note: the symbol " ." is important, it will tell the script to automatically install Django into the directory you currently choose

 

django-admin.py
  is a script that will automatically create directories and files. The directory structure is:

 

djangogirls
├───manage.py
└───mysite
        settings.py
        urls.py
        wsgi.py
        __init__.py

Then in the settings.py file, find the line that contains the `TIME_ZONE</0> field, and change the time zone to the time zone of your region. which is:

 

python
TIME_ZONE = 'Europe/Berlin'
 Mainland China can be changed to Asia/Shanghai.
 Scroll down to the very bottom , just below the STATIC_URL  entry. Add a new line:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
 
 (2). To create a database for the blog, run the following command in the console:

 

 

python manage.py migrate
 (3). Start the web server:

 

 

python manage.py runserver
 (4). Check whether the server of your site is already running.

 

   Enter this URL:

 

http://127.0.0.1:8000/
 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326931325&siteId=291194637