Deploy Django projects in BAE, and deploy django In bae

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.