Deploy Django projects in BAE, and deploy django In bae
1. First create an application name on the BAE and purchase a space
2. git the application folder to the local device. At this time, the folder will contain three more files: app. conf, favicon. ico, index. py.
3. Create a local project: myblog in the application folder, and create a project app: blog in the local project.
4. modify the content of the app. conf file:
1 handlers: 2 - url : /static/(.*) 3 script : /myblog/static/$1 4 - url : /templates/(.*) 5 script : /templates/$1 6 - url : /.* 7 script : index.py 8 9 - expire : .jpg modify 10 years10 - expire : .swf modify 10 years11 - expire : .png modify 10 years12 - expire : .gif modify 10 years13 - expire : .JPG modify 10 years14 - expire : .ico modify 10 years
5. Modify the index. py file:
1 #-*- coding:utf-8 -*- 2 3 import os 4 import sys 5 6 os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' 7 8 path = os.path.dirname(os.path.abspath(__file__)) + '/mysite' 9 if path not in sys.path:10 sys.path.insert(1, path)11 12 from django.core.wsgi import get_wsgi_application13 from bae.core.wsgi import WSGIApplication14 application = WSGIApplication(get_wsgi_application())
6. Introduction of static files:
(1) create a statics folder in the myblog File
(2) Add STATIC_ROOT = OS. path. join (BASE_DIR, 'statics ')
(3) Use python manage. py collectstatic to copy all static files to the statics folder.
(4) copy the admin files in statics to the static folder.
(5) Delete the statics folder and STATIC_ROOT = OS. path. join (BASE_DIR, 'statics ')
7. git to BAE, and then deploy and release