先帖代碼跟項(xiàng)目結(jié)構(gòu)項(xiàng)目結(jié)構(gòu)
├── gameOps │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py ├── dufgame │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── models.py │ ├── signals.py │ ├── templates │ │ └── dufindex.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── run.py ├── static │ ├── css │ │ ├── base.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ └── bootstrap-theme.min.css │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery.js │ ├── jquery.min.js │ └── npm.js └── templates ├── base.html ├── leftpage.html └── tmp.html
templates/base.html 為基礎(chǔ)模板
訪問:http://192.168.50.137:8000/呈現(xiàn)的是base.html內(nèi)容
dufgame/templates/dufindex.html中的內(nèi)容部分繼承了templates/base.html中的內(nèi)容
訪問:http://192.168.50.137:8000/duf/呈現(xiàn)的是dufgame/templates/dufindex.html中的內(nèi)容
gameOps/setting.py中關(guān)于靜態(tài)文件的設(shè)置
STATIC_URL = '/static/' STATICFILES_DIRS = (os.path.join(BASE_DIR,'static'),)
templates/base.html中的靜態(tài)文件內(nèi)容
<meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Game Ops</title> {% load staticfiles %} <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet"> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <link href="{% static "css/base.css" %}" rel="stylesheet">
訪問:http://192.168.50.137:8000/duf/打印的日志信息
INFO "GET /duf/ HTTP/1.1" 200 8634 INFO "GET /static/css/base.css HTTP/1.1" 304 0 WARNING "GET /duf/static/js/jquery.min.js HTTP/1.1" 404 2789 WARNING "GET /duf/static/js/bootstrap.min.js HTTP/1.1" 404 2798 WARNING "GET /duf/static/js/jquery.min.js HTTP/1.1" 404 2789 WARNING "GET /duf/static/js/bootstrap.min.js HTTP/1.1" 404 2798
問題來了,我的靜態(tài)文件要怎么設(shè)置才能在訪問http://192.168.50.137:8000/duf/時(shí)候也能調(diào)用到。
擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...