- use
django-admin startproject **projectname**
to create an empty project - use github to store the project
- use
python3 manage.py runserver 0.0.0.0:8000
to run the server - add
**ip_address**
to ALLOWED_HOSTS insetting.py
- we can use
ag ALLOWED_HOSTS
to find the path and line of that name
- we don't want
__pycache__
to be uploaded to github so we create a file '.gitignore' to myapp/ and add '**/pycache' to the file.
- use
python3 manage.py startapp **game**
- run
python3 manage.py migrate
to update
- run
python3 manage.py createsuperuser
.
- add a 'init.py' to the folder
- change the string after TIMEZONE in setting.py to Asia/Shanghai
.
|-- README.md
|-- db.sqlite3
|-- game
| |-- __init__.py
| |-- __pycache__
| | |-- __init__.cpython-38.pyc
| | |-- admin.cpython-38.pyc
| | |-- apps.cpython-38.pyc
| | |-- urls.cpython-38.pyc
| | `-- views.cpython-38.pyc
| |-- admin.py
| |-- apps.py
| |-- migrations
| | |-- __init__.py
| | `-- __pycache__
| | `-- __init__.cpython-38.pyc
| |-- models
| | |-- __init__.py
| | `-- __pycache__
| | `-- __init__.cpython-38.pyc
| |-- static
| | |-- css
| | | `-- game.css
| | |-- image
| | | |-- menu
| | | | `-- background.gif
| | | |-- playground
| | | `-- settings
| | `-- js
| | |-- dist
| | | `-- game.js
| | `-- src
| | `-- zbase.js
| |-- templates
| | |-- menu
| | |-- multiends
| | | `-- web.html
| | |-- playground
| | `-- settings
| |-- tests.py
| |-- urls
| | |-- __init__.py
| | |-- __pycache__
| | | |-- __init__.cpython-38.pyc
| | | `-- index.cpython-38.pyc
| | |-- index.py
| | |-- menu
| | | |-- __init__.py
| | | |-- __pycache__
| | | | |-- __init__.cpython-38.pyc
| | | | `-- index.cpython-38.pyc
| | | `-- index.py
| | |-- playground
| | | |-- __init__.py
| | | |-- __pycache__
| | | | |-- __init__.cpython-38.pyc
| | | | `-- index.cpython-38.pyc
| | | `-- index.py
| | `-- settings
| | |-- __init__.py
| | |-- __pycache__
| | | |-- __init__.cpython-38.pyc
| | | `-- index.cpython-38.pyc
| | `-- index.py
| `-- views
| |-- __init__.py
| |-- __pycache__
| | |-- __init__.cpython-38.pyc
| | `-- index.cpython-38.pyc
| |-- index.py
| |-- menu
| | `-- __init__.py
| |-- playground
| | `-- __init__.py
| `-- settings
| `-- __init__.py
|-- manage.py
|-- myapp
| |-- __init__.py
| |-- __pycache__
| | |-- __init__.cpython-38.pyc
| | |-- settings.cpython-38.pyc
| | |-- urls.cpython-38.pyc
| | `-- wsgi.cpython-38.pyc
| |-- asgi.py
| |-- settings.py
| |-- urls.py
| `-- wsgi.py
`-- scripts
`-- compress_game_js.sh
36 directories, 54 files
####程序运行逻辑:
- 用户与前段javascript交互js监听函数返回一个路由
- 返回的路由有django中的url进行处理后返回对应的views哪的函数
- views内部函数负责处理传过来的值以及后端逻辑#程序运行逻辑: