pip3 install django==1.11.22css
目前來說1.11.22
版本比較穩定html
django-admin startproject django項目名稱
加載css,js相關文件配置python
首先要建立static文件夾且把css已經js丟進去django
STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) #若是,少了加載css會報500的錯誤,若是麼有配置STATICFILES_DIRS會報404的錯誤
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', #'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]
讀取html文件的時候session
'DIRS': [os.path.join(BASE_DIR, 'templates')]
非本機訪問socket
ALLOWED_HOSTS = ['指定ip1','指定ip2'] ALLOWED_HOSTS = ['*'] #所有ip
命令行啓動django時候綁定ip和端口python manage.py runserver ip:port
網站
pycharm中修改url
LANGUAGE_CODE = 'zh-hans' #django1.8之後不支持zh-cn TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = False #默認是Ture,時間是utc時間,因爲咱們要用本地時間,所用手動修改成