复制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)
|