标签:加载 war option 访问 pytho install uri admin 修改端口号
pip3 install django==1.11.22
目前来讲1.11.22
版本比较稳定
django-admin startproject django项目名称
加载css,js相关文件配置
首先要创建static文件夹且把css已经js丢进去
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文件的时候
'DIRS': [os.path.join(BASE_DIR, 'templates')]
非本机访问
ALLOWED_HOSTS = ['指定ip1','指定ip2']
ALLOWED_HOSTS = ['*'] #全部ip
命令行启动django时候绑定ip和端口python manage.py runserver ip:port
pycharm中修改
标签:加载 war option 访问 pytho install uri admin 修改端口号
原文地址:https://www.cnblogs.com/pythonywy/p/11317597.html