Krishna Teja Karnam
Krishna Teja Karnam

Reputation: 133

Unable to host Django app on Google Cloud Platform

I have built a django app and its working fine in local machine, I tried hosting it in Google Cloud Platform.

  1. Created a project Google Console
  2. Created a django VM Instance
  3. I cloned the repo from bitbucket
  4. Installed all the dependencies
  5. Created a database and made sure same credentials are used in settings.py
  6. python manage.py syncdb - this is executed
  7. Python manage.py collectstatic - this is executed

When I created a VM Instance I was given a dedicated IP, there is already a app called Project. I cloned the repo beside this folder (this is the IP https://130.211.79.74 and this is the link to the default app https://130.211.79.74/Project). I tried accessing my app and I see a 404 error. Is there anything that am missing.

Upvotes: 0

Views: 506

Answers (1)

Raphaël Braud
Raphaël Braud

Reputation: 1519

Use the good paths in your wsgi.py file :

import os
import sys
sys.path.append('installdir/apps/django/django_projects/my_new_project')
os.environ.setdefault("PYTHON_EGG_CACHE", "installdir/apps/django/django_projects/my_new_project/egg_cache")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_new_project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Don't forget to reload Apache so that your modifications are taken into account.

Upvotes: 1

Related Questions