Skip to content

Instantly share code, notes, and snippets.

@jspw
Last active August 12, 2020 20:09
Show Gist options
  • Save jspw/3365c2e6767431ec36ca046089d17e0c to your computer and use it in GitHub Desktop.
Save jspw/3365c2e6767431ec36ca046089d17e0c to your computer and use it in GitHub Desktop.
Host Your Django project in pythoneverywhere.com

Here i am going to show the steps to host your fucking django project in the pythoneverywhere.com !

  • Go to pythoneverywhere.com
  • create account and login
  • Go to consoles
  • Select bash console
  • Create virtual environment for python
    • mkvirtualenv --python=python3.8 envname
  • Your environment will be activated and in bash you will see the envname in parenthesis
  • Install django
    • pip install -U django==3.0.3
    • check django path
      • which django-admin.py
  • install necessary packages pip instal xyz
  • Clone git repo git clone repo.git
  • Go to dashboard of pythoneverywhere.com and go to Web
  • Select create new web app
  • next
  • select manual configuration
  • next next done !
  • here you will see the url for your project clik and you will see hello world page which is default for pyton
  • config webapp
  • setvirtualenv path which u find in console using which django-admin.py
  • set source code /home/username/projectname
  • static files
    • set /static/admin/ as /home/jspw/.virtualenvs/blog/lib/python3.8/site-packages/django/contrib/admin/static/admin
    • set /static/ as your project static folder path as mine is /home/jspw/shifat.com/blog/static
  • set Virtualenv dir as /home/username/.virtualenvs/env_name
  • Edit WSGI configuration file as the file given below
  • Done ! Clik on the reload in the webapp page then go to the website url and boom!!!

Note : Chekc settings.py file and you have allowed your host url.

import os
import sys
## assuming your django settings file is at '/home/jspw/mysite/mysite/settings.py'
## and your manage.py is is at '/home/jspw/mysite/manage.py'
path = '/home/jspw/mysite' #path of your project
if path not in sys.path:
sys.path.append(path)
os.chdir(path)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', "food_menu_project.settings") #projectname.settings
import django
django.setup()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment