Mrli
别装作很努力,
因为结局不会陪你演戏。
Contacts:
QQ博客园

复制Django项目时需要注意、修改的地方

2019/09/15 Python 后端 Django
Word count: 242 | Reading time: 1min

复制Django项目:

manage.py中需要修改的地方

1
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "window.settings")

settings.py中需要修改的地方

1
2
3
4
5
"""
Django settings for window project.
"""
ROOT_URLCONF = 'window.urls'
WSGI_APPLICATION = 'window.wsgi.application'

urls.py中需要改动的地方

1
"""window URL Configuration

wsgi.py中需要修改的地方

1
2
3
"""
WSGI config for window project.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "window.settings")

django可复用模板

在project_name文件下的*.py

再在终端键入django-admin startproject xx --template=* (*为文件夹中py文件名)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import sys
from django.conf import settings
DEBUG = os.environ.get('DEBUG','on')== 'on'
ALLOW_HOSTS = ['*']
SECRET_KEY = os.environ.get('SECRET','{{ secret_key }}')
settings.configure(
DEBUG = DEBUG,
ALLOW_HOSTS = ALLOW_HOSTS,
SECRET_KEY = SECRET_KEY,
ROOT_URLCONF = __name__,
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
)
from django.conf.urls import url
from django.core.wsgi import get_wsgi_application
from django.http import HttpResponse

def index(request):
return HttpResponse('Hello Word')

urlpatterns = (
url(r'$',index),
)

application = get_wsgi_application()

if __name__ == '__main__':
from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

Author: Mrli

Link: https://nymrli.top/2018/10/24/复制Django项目时需要注意、修改的地方/

Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.

< PreviousPost
XShell通过SSH远程连接云服务器通过SSH远程连接云服务器
NextPost >
Python Web——Django笔记(一)
CATALOG
  1. 1. 复制Django项目:
    1. 1.1. django可复用模板