Webapp deploy to www.pythonanywhere.com
-
Visit and register https://www.pythonanywhere.com/
-
Push your project to github
-
Start
bash console
at pythonanywhere -
Git clone your project to pythonanywhere
-
Create
virtual env
- cd to clonned project dir
python3 -m venv env
-
Activate
venv
and install all dependencies -
Create
new custom webapp
at pythonanywhere -
Fill in all the gaps
- Source code: - the path to the folder with
manage.py
(/home/denniskot/django-dummy/src) - Virtualenv:
- The path to the folder with virtual env (
/home/denniskot/django-dummy/env
)
- The path to the folder with virtual env (
- Static files:
- Create in bash conslole folders
static
andmedia
on the same level assrc
folder. (/home/denniskot/django-dummy/static and /home/denniskot/django-dummy/media) - Add url
/static/
and directory/home/denniskot/django-dummy/static
- Add url
/media/
and directory/home/denniskot/django-dummy/media
- Create in bash conslole folders
- Source code: - the path to the folder with
-
Edit WSGI configuration file
(click the link)-
Comment "hello world" section
-
Find "django" section
- Comment out django section
- Change
path
to the folder with your 'manage.py' file (/home/denniskot/django-dummy/src
) - Change
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
wheremysite
is the project/module/folder name with 'settings.py' file (os.environ['DJANGO_SETTINGS_MODULE'] = 'proj.settings'
)
# My WSGI file # +++++++++++ DJANGO +++++++++++ # To use your own django app use code like this: import os import sys # assuming your django settings file is at '/home/denniskot/mysite/mysite/settings.py' # and your manage.py is is at '/home/denniskot/mysite/manage.py' path = '/home/denniskot/django-dummy/src' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'proj.settings' # then: from django.core.wsgi import get_wsgi_application application = get_wsgi_application()
-
-
Edit settings.py
- edit
ALLOWED_HOSTS = ['yourloginname.pythonanywhere.com',]
- add lines below STATIC_URL
# Change path in *_ROOT according to your static and media path MEDIA_URL = '/media/' STATIC_ROOT = '/home/denniskot/django-dummy/static' MEDIA_ROOT = '/home/denniskot/django-dummy/media'
- edit
-
reload webapp