Skip to content

Instantly share code, notes, and snippets.

@mrts
Last active December 16, 2019 15:37
Show Gist options
  • Save mrts/dd815fe9feb3d645b5d6f5656d609a97 to your computer and use it in GitHub Desktop.
Save mrts/dd815fe9feb3d645b5d6f5656d609a97 to your computer and use it in GitHub Desktop.
PythonAnywhere Django setup
  1. Open Bash console in PythonAnywhere

  2. Make project directory

  3. Setup virtualenv

     virtualenv --python=python3.6 venv
     . venv/bin/activate
    
  4. Install Django

     pip install django
    
  5. Start Django project

     django-admin startproject pythonanywhere
     cd pythonanywhere/
    
  6. Add site to ALLOWED_HOSTS in settings.py

     ALLOWED_HOSTS = ['mrts.pythonanywhere.com']
    
  7. Create DB

     python manage.py migrate
    
  8. Open Web tab in PythonAnywhere, add new web app, choose manual configuration

  9. Change

    • Code: /home/mrts/django-tutorial/pythonanywhere
    • Virtualenv: /home/mrts/django-tutorial/venv
  10. Edit WSGI config file:

    import os
    import sys
    
    path = os.path.expanduser('~/django-tutorial/pythonanywhere')
    if path not in sys.path:
        sys.path.append(path)
    os.environ['DJANGO_SETTINGS_MODULE'] = 'pythonanywhere.settings'
    
    from django.core.wsgi import get_wsgi_application
    from django.contrib.staticfiles.handlers import StaticFilesHandler
    application = StaticFilesHandler(get_wsgi_application())
    
@yoongyo
Copy link

yoongyo commented Jun 19, 2018

아니 극

아니그게 뭐여ㅓ

@yoongyo
Copy link

yoongyo commented Jun 19, 2018

ㅁㅇㄹㄴㅁㄻㄴㄹㅁㅇㄻㅇㄹㄴ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment