I have been trying to deploy my Django app to Vercel and I am getting this error. Any idea?
Missing variable `handler` or `app` in file "qr_project/wsgi.py".
So I found out that vercel looks for app not application (which is comes default with django-admin startproject mysite). So I changed my wsgi.py file like this
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_project.settings')
application = get_wsgi_application()
app = application
Related
I'm trying to deploy a Django App in OVH Hosting and, after some hard exploration and try-error, I keep getting an issue.
File "/usr/share/passenger/helper-scripts/wsgi-loader.py", line 381, in <module>
handler = RequestHandler(server_socket, sys.stdin, app_module.application)
AttributeError: module 'passenger_wsgi' has no attribute 'application'
OVH/Passenger proccess feedback
Apart from all the files created at startapp by Django and all the code I wrote I added the following file 'passenger_wsgi.py' on the root of the app directory. I used two differents versions:
First:
import MyApp.wsgi
application = MyApp.wsgi.application
Second:
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
In the runtime configuration of OVH hosting the application launch script set is 'manage.py'. SECRET_KEY and DJANGO_SETTINGS_MODULE are declared in the environment variables.
Hi everybody I tried to deploy my django project with apache, mod_wsgi in windows.
I splited my settings.py like this:
source root folder
project folder
apps
config
settings
init.py
base.py
local.py
prod.py
init.py
asgi.py
urls.py
wsgi.py
myenv
After I splited settings.py,
Mod_wsgi failed to exec python scripts file :
'C:/user/users/desktop/source_root_folder/project_folder/wsgi.py'.
Mod_wsgi also show the exception that Exception occurred processing WSGI script :
'C:/user/users/desktop/source_root_folder/project_folder/wsgi.py'
In Apache24 error log, 'C:/user/users/desktop/source_root_folder/project_folder/wsgi.py'
application = get_wsgi_application()
error occured.
# project_folder/wsgi.py
import os
from django.core.wsgi import get_wsgi_application
import sys
sys.path.append('C:/Apache24/htdocs/ C:/user/users/desktop/source_root_folder')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project_folder.config.settings'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_folder.config.settings')
application = get_wsgi_application()
how can i deal with those errors?
please give me some helps.
you need to specify the *.py settings file:
os.environ['DJANGO_SETTINGS_MODULE'] = 'project_folder.config.settings.init'
So I wanted to deploy my first django application on a cherryPy webserver using wsgi. And I have issues with os.environ['DJANGO_SETTINGS_MODULE']. When trying to run application callable it throws error, that module is not found. Project structure:
ResourceManager
ResourceManager
ResourceManager
__init__.py
cherryserver.py
settings.py
urls.py
wsgi.py
SimpleResourceManager
migrations
__init__.py
admin.py
apps.py
models.py
serializers.py
tests.py
urls.py
views.py
manage.py
wsgi.py file:
import os
import sys
from django.core.wsgi import get_wsgi_application
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0,BASE_DIR)
os.environ['DJANGO_SETTINGS_MODULE'] = 'ResourceManager.settings'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ResourceManager.settings')
application = get_wsgi_application()
cherryserver.py:
import cherrypy
from ResourceManager.ResourceManager.wsgi import application
if __name__ == '__main__':
# Mount the application
cherrypy.tree.graft(application, "/")
# Unsubscribe the default server
cherrypy.server.unsubscribe()
# Instantiate a new server object
server = cherrypy._cpserver.Server()
# Configure the server object
server.socket_host = "0.0.0.0"
server.socket_port = 8080
server.thread_pool = 30
# Subscribe this server
server.subscribe()
cherrypy.engine.start()
cherrypy.engine.block()
Application works fine when using command runserver 8080, but when i tried to run it on different server. It says ModuleNotFoundError: No module named "ResourceManager.settings".
So i tried: Change where cherryserver.py is located in directory, I have added additional lines of code to wsgy.py file and I'm running out of ideas what is wrong when I'm deploying my app on different server. Why I'm using cherryPy, well I have to test 5 web servers that are based on python.
Try changing from:
from ResourceManager.ResourceManager.wsgi import application
To:
from wsgi.py import application
This is because they are located in the same directory, if this does not work just mess around with the from as it seems that your path to the wsgi file is wrong.
Trying to deploy my project on pythonanywhere.
python3.4
Django 1.8.7
Username - GriMel
Project name - TwDTutor
wsgi configuration file
import os
import sys
path = '/home/GriMel/TwDTutor'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'TwDTutor.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Static files
/static/admin /home/GriMel/.virtualenvs/rango/lib/python3.4/site-packages/django/contrib/admin/static/admin
/static/ /home/GriMel/TwDTutor/rango/static
Get the error
django.core.exceptions.ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
That error usually indicates that there's a Django version mismatch so you probably haven't set the virtualenv correctly on the web app tab.
I have been developing a django site on Heroku and using dj-static in my wsgi.py. I am now about to move my site static files onto Amazon. Do I need to now remove the references to dj-static from my wsgi.py file? I'm concerned about the following lines of code. What would be the correct thing to do? Do they need to go? If so, what do I put in their place?:
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
Thanks,
Euan
If you are serving files using django-storages you don't need to use dj-static anymore. dj-static is only used when you want to serve the static files using a WSGI server like gunicorn. In your case you are using Amazon's servers.
To answer your question, you can revert to the default wsgi.py file which looks something like this:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
You can also remove dj-static from your virtualenv and from requirements.txt