'Error while deploying Django app on cpanel(shared hosting)

I m new to django. I created a web with dajngo,and successfully deployed it in the server

The python app has been successfully setup and virtual environment has been setup. but while running the web it gives me "Server Error (500)" I don't know whats the problem.

I think error is in "wsgi.py" file but i'm unable to idenify it. My wsgi file:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'karan_web.settings')
application = get_wsgi_application()

my "passenger_wsgi.py" file is:

import imp
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
wsgi = imp.load_source('wsgi', 'karan_web/wsgi.py')
application = wsgi.application

can someone help me with it;



Solution 1:[1]

Sorry for the late answer, I had figured out the as to this just forgot to post it. As I stated in my question, the actual problem was in passenger_wsgi.py, the django server starts with the wsgi.py and act as the gate way to the Django server. So whenever a Django project is uploaded on the hosting server, It creates a passenger_wsgi.py file and one default wsgi.py, address of which is provided in passenger_wsgi.py by default. So we just need to change that address and provide the address of our own wsgi.py in the project

In my case it was

import os
import sys
from karan_web import wsgi
application = wsgi.application

Solution 2:[2]

just edit in passenger_wsgi.py the following code.

from karan_web.wsgi import application

Solution 3:[3]

You need to check if your code syntax is correct and running properly. If its still doesn't work try to delete and recreate your database in cpanel and check if you have made all necessary migrations, don't forget to restart your python app. If after all these it still doesn't work check if all your files have the correct file permission(766).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 aditya gupta
Solution 2 Gaurab Khatri
Solution 3 Onojakpor Ochuko