First Django project and deployment to Sina App Engine

Source: Internet
Author: User

Sina APP engine short for SAE, is a better site hosting platform, is now said to be completely free, in fact, everyone allocates a very small resource quota, in a certain range of use without consumption of cloud beans (SAE billing), for individual learning and research enough, similar to the Gae ( Google App Engine) and Bae (Baidu App Engine), Gae body in the domestic do not have to think too much, unless the love toss, Bae is also good, but to spend money, the lowest configuration as long as a few cents a day, but also cheap. Of course, if the money is rich or the flow to a certain extent, you can consider the cloud server.

Currently, a Django project has been deployed on the SAE and the steps are documented as follows:

Open Eclipse, choose Create a Pydev Django Project input project name, select Interpreter Enter Django settings here can set the database type and configuration, I choose MySQL here, And because my root user did not set the password, so left blank, if the password is set, you need to fill in the password such a Django project is built up, because the deployment to Apache when the style is required, so add the static folder under SRC, will python27\lib\ Copy the files under Site-packages\django\contrib\admin\static to the newly added static folder, change the httpd.conf file
1 alias/static d:/workspace/python/hellodjango/src/static2 <Directoryd:/workspace/python/hellodjango/src/static>3 allowoverride None4 Options None5 Order Allow,deny6  allow from all7 </Directory>8  9 Wsgiscriptalias/django "D:\Workspace\Python\HelloDjango\src\HelloDjango\wsgi.py"Ten Wsgipythonpath "D:\WORKSPACE\PYTHON\HELLODJANGO\SRC" One   A <Directory"D:\Workspace\Python\HelloDjango\src\HelloDjango"> - Order Allow,deny -  allow from all the </Directory>     

Sae:sae after using SVN to upload files checkout, Copy the folder under the SRC of the above item to the checked out folder under version 1, the current Django version of the SAE is up to 1.5, and if you need 1.8, you need to upload the 1.8 version of the Django folder to the SAE and modify the Config.yamllibraries :-Name: "Django" version: "1.5" need to note spaces modify Index.wsgi file
1 ImportSYS2 ImportOs.path3   4os.environ['Django_settings_module'] ='hello.settings'5Sys.path.append (Os.path.join (Os.path.dirname (__file__),'Hello'))6 7 ImportSAE8  fromHelloImportWsgi9 Tenapplication = Sae.create_wsgi_app (wsgi.application)

If you need to see the Django version, comment the code above and add it in Index.wsgi
1 #Coding=utf-82 ImportSAE3  4  5 ImportDjango6  7 defapplication (environ, start_response):8Start_response ('OK', [('Content-type','Text/plain')])9s=Str (Django. VERSION)Ten     returnS

This will print out the Django version. If MySQL is used, because the SQL on the SAE is not locally connected, the MySQL connection configuration on the local and on the SAE is not the same, and you can consider the following configuration in settings.py
1debug= notEnviron.get ("app_name","")2 ifDebug:3     #Local4mysql_db ="App_lsblog"5Mysql_user ="Root"6Mysql_pass ="Root"7Mysql_host_m ="127.0.0.1"8Mysql_port ="3306"9 Else:Ten     ImportSae.const Onemysql_db =Sae.const.MYSQL_DB AMysql_user =Sae.const.MYSQL_USER -Mysql_pass =Sae.const.MYSQL_PASS -Mysql_host_m =Sae.const.MYSQL_HOST theMysql_port =Sae.const.MYSQL_PORT -mysql_host_s =Sae.const.MYSQL_HOST_S -  -DATABASES = { +     'default': { -         'ENGINE':'Django.db.backends.mysql', +         'NAME': mysql_db, A         'USER': Mysql_user, at         'PASSWORD': Mysql_pass, -         'HOST': Mysql_host_m, -         'PORT': Mysql_port, -     } -}

First Django project and deployment to Sina App Engine

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.