Python Django
▌Introduction
Django is a free and open-source web framework for
Python.
▋Related articles
▌Environment
▋Python 3.6.2
▋Django 1.11.5
▌Implement
▋Install Django
$
mkdir Django
$
cd Django
$ python -m venv venv/ShopCart
$ cd venv/ShopCart
$ scripts\activate.bat
|
$
python -m pip install Django
|
▋Create a new Django project
$
django-admin startproject shopcart
|
The
project’s default files are as following.
▋__init__.py
This file maks Python treat
the directory which has it as a module.
It's the first file being loaded in a module, so we can run some codes when
it's loaded.
▋settings.py
For example, SECRET_KEY =
'xxxxxxxxxxxxxxxxxxx' is described as following...
(From django documentation)
▋urls.py
We can define Url Patterns in
this file.
▋wsgi.py
An entry-point for
WSGI-compatible web servers to serve your project. For more information on
WSGI(Web Server Gateway Interface), see WIKI.
▋Start it
Use the following
command to start the web server.
$
python shopcart\manage.py runserver
|
▌Reference
沒有留言:
張貼留言