Deploying Django Project at Pythonanywhere

By: summonagus ● at July 21, 2017, 6:46 p.m. ● and modified at July 21, 2017, 8:44 p.m.
Posted under: #APP, #Django, #News, #Project ● Your ip address: 54.224.184.33 ● views: 67 times.

AD Space Available, Book Now!

PythonAnywhere is an online Integrated Development Environment (IDE) and Web hosting service based on the Python programming language. It provides in-browser access to server-based Python and Bash Command-line interfaces, along with a code editor with Syntax highlighting. Program files can be transferred to and from the service using the user's browser. Web applications hosted by the service can be written using any WSGI-based application framework. (wikipedia)

Makesure you created an account and logged in first, before doing this tutorial.

1. Go to https://www.pythonanywhere.com/user/yourusername/webapps/, and create new Django.

Create new Django project at Pythonanywhere

2. Create your virtualenv

$ mkvirtualenv env-mysite

Create virtualenv in Pythonanywhere

3. Take your django project

You can use SSH, git, or other else to take your django project into pythonanywhere. In this case, I clone my Django project via git for easilier.

$ git clone https://github.com/agusmakmun/Django-Blog-Python-Learning.git

Cloning django project

4. Sync the virtualenv

Go to https://www.pythonanywhere.com/user/yourusername/webapps/, and change to your virtualenv that you created before.

Virtualenv Setting

5. Edit file settings.py

Don't miss to change common settings inside your file settings.py, such as:

ALLOWED_HOSTS = [u'yourusername.pythonanywhere.com']
# default static files settings for PythonAnywhere. # see https://help.pythonanywhere.com/pages/DjangoStaticFiles for more info MEDIA_ROOT = u'/home/yourusername/swotproject/media' MEDIA_URL = '/media/' STATIC_ROOT = u'/home/yourusername/swotproject/static'
STATIC_URL = '/static/'

6. Reload your web app

Reload your web app and then check at your site..

Reload app



Author

summonagus

Python Developer, Linux Enthusiast, and Senior writer at python.web.id
Website: https://github.com/agusmakmun
blog comments powered by Disqus