Deploying a Django Project on Pythonanywhere

Source: Internet
Author: User
Tags virtual environment virtualenv

Http://www.jianshu.com/p/91047e3a4ee9

Put the item on git, then upload ssh on pathonanywhere to git, create it first, and then copy the project from git to the root of Pathonanywhere/home/xqnq2007

1 Create a virtual environment,

mkvirtualenv rango
Install various packages in a virtual environment, which avoids some problems with insufficient permissions


2
Configure Virtualenv

Write the corresponding file path correctly

Once the web app is created, the Web Web App-related configuration information you created will appear on the tab page, which I call the Project management page. In this page find Virtualenv , click Enter a path to a virtualenv, if desired , replace with your own virtualenv path, such as: /home/<username>/.virtualenvs/rango .

3

Configuring WSGI Code

On the Project management page WSGI configuration file: [/var/www/<username>_pythonanywhere_com_wsgi.py] , click the py file, keep the following code, and delete (or comment out) the rest of the code:

# +++++++++++ Django +++++++++++# to use your own Django app with code like this:Import OSImport sys### Assuming your Django settings fileIsAt'/home/<username>/mysite/mysite/settings.py ' # #And your manage.pyIsIsAt'/home/<username>/mysite/manage.py 'Path ='/home/<username>/tango_with_django 'IfPathNotIn Sys.Path:sys.Path.append (Path) #os. environ[' Django_settings_module '] =' Tango_with_django_project.settings ' # # #ThenFor Django >=1.5:from Django.core.wsgiImport get_wsgi_applicationapplication = Get_wsgi_application () # #OrFor older Django <=1.4#Import django.core.handlers.wsgi#application = Django.core.handlers.wsgi.WSGIHandler ()

4 Configuring Static files
Found on the Project management pageStatic filesClickEnter URLInput/static/admin, click the correspondingEnter pathInput/home/<username>/.virtualenvs/rango/lib/python2.7/site-packages/django/contrib/admin/static/admin, the above steps add aadminThe static file of the relevant page, add the static file in the app below, click againEnter URLInput/static/, click the correspondingEnter pathInput/home/<username>/tango_with_django/static/
Here Tango with Django's tutorial also has a pit, which corresponds to the/static/OfpathFor/home/<username>/tango_with_django/tango_with_django_project/static, one more of the pathstango_with_django_project
5 Importing the database, importing it from the command line in bash
debugging tips, see error log
http://blog.csdn.net/zhu_free/article/details/46279725
https://my.oschina.net/hding/blog/615243
1190000009240824
https://www.v2ex.com/t/195207
Http://www.cnblogs.com/kuihua/p/5577276.html
Http://www.cnblogs.com/llw1121/p/6957039.html

Deploying a Django Project on Pythonanywhere

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.