Django 1.10 ?????????????????????????????????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django 1.10 ?????????????????????????????????相关的知识,希望对你有一定的参考价值。
??????????????? manage port set dir ati path ?????? init
???????????????Django 1.10
?????????Django???????????????????????????
???????????????
1.???????????????????????????app????????????2????????? static ??? templates
??????????????????(DjangoProject ?????????????????? blogs ???app???????????????????????????blogs???)
DjangoProject/ ????????? db.sqlite3 ????????? manage.py ????????? DjangoProject ??? ????????? __init__.py ??? ????????? settings.py ??? ????????? urls.py ??? ????????? wsgi.py ????????? blogs ??? ????????? admin.py ??? ????????? apps.py ??? ????????? __init__.py ??? ????????? migrations ??? ??? ????????? __init__.py ??? ????????? models.py ??? ????????? static ??? ??? ????????? style.css ??? ????????? templates ??? ??? ????????? index.html ??? ????????? tests.py ??? ????????? views.py ????????? templates
static????????????????????????templates???????????????????????????
2.??????setting.py
?????? STATIC_URL = ???/static/??? ????????????????????????????????????
STATIC_ROOT = os.path.join(BASE_DIR, ???static???)
?????????????????????????????????????????????????????????????????????
# Static files (CSS, javascript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = ???/static/??? STATIC_ROOT = os.path.join(BASE_DIR, ???static???)
3.?????? urls.py
???urls.py?????????2??????
from django.conf import settings from django.conf.urls.static import static
??????????????????
+ static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
??????????????????????????????????????????????????????????????????
from django.conf.urls import url from django.contrib import admin
form blogs import views as blogs_views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ url(r???^admin/???, admin.site.urls),
?????? url(r???^$???, blogs_views.index), ] + static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
4.????????????????????????
?????????????????????????????? static??????????????????????????????????????? templates??????
?????????????????????
<link rel="stylesheet" href="/static/style.css">
?????????/static/????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????
以上是关于Django 1.10 ?????????????????????????????????的主要内容,如果未能解决你的问题,请参考以下文章
Django 1.10 ?????????????????????????????????
获取服务器响应 (400):来自 Pypi 的无效分类器“Framework :: Django :: 1.10”