I'm having an issue deploying my first Django project.
Here's my config.yml:
global:
application_name: testapp
branch: null
default_ec2_keyname: aws-eb
default_platform: Python 3.8 running on 64bit Amazon Linux 2
default_region: us-west-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: null
workspace_type: Application
And here's my django.config:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: djangoproject.wsgi:application
I have followed this doc. But after I did eb create testapp-env, I get 502 error:
image of the error
I will provide further information if you need. Thank you in advance for your help.
Here's the error in web.stdout.log:
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
UPDATE
My django project uses python-socketio, and here's my wsgi.py:
from django.core.wsgi import get_wsgi_application
import socketio
from post.socketioserver import sio # <- it's just my socket io code
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoproject.settings')
django_app = get_wsgi_application()
application = socketio.WSGIApp(sio, django_app)
I get another error:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
You need to set the DJANGO_SETTINGS_MODULE environment variable:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: djangoproject.wsgi:application
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: "djangoproject.settings"
Also you need to edit your wsgi.py file because you are accessing an app before Django setup:
import django
django.setup()
from django.core.wsgi import get_wsgi_application
import socketio
from post.socketioserver import sio # <- it's just my socket io code
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoproject.settings')
django_app = get_wsgi_application()
application = socketio.WSGIApp(sio, django_app)
Related
I'm trying to deploy a basic Django project on AWS using ElasticBean. I tried everything, but can't understand what mistake I have done. So I will summarise here all 'solutions' on the internet. Please help !
First of, this is my Django project:
.ebextensions
-django.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: ebdjango.wsgi:application
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: ebdjango.settings
.elasticbeantalk
branch-defaults:
default:
environment: eb-env
global:
application_name: ebdjango
branch: null
default_ec2_keyname: null
default_platform: Python 3.8
default_region: us-west-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: null
workspace_type: Application
settings.py
ALLOWED_HOSTS = ['http://ebdjango-env.eba-b3pcnpc8.us-east-1.elasticbeanstalk.com/']
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ebdjango.settings')
application = get_wsgi_application()
requirements.txt
Django==3.2
gunicorn==20.1.0
There is nothing in my Django app, no templates, no modules. I created it to be able to upload it. I'm using Django 3.2 and Python 3.8
When loading the webpage (CNAME): 502 Bad Gateway / nginx/1.22.1
When looking the log file I see this error: web: ModuleNotFoundError: No module named 'ebdjango.wsgi'
The entire project is available here: https://github.com/mkchmura/AWS-EB-CLI.git
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
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'
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'm trying to upgrade from Django 1.6 to 1.7.
When running python manage.py runserver, I got the following error :
django.core.exceptions.ImproperlyConfigured: WSGI application 'myapp.wsgi.application' could not be loaded; Error importing module: 'cannot import name get_path_info'
Here's the corresponding line in my settings.py :
WSGI_APPLICATION = 'myapp.wsgi.application'
Here's my wsgi.py file :
import os
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "myapp.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
from dj_static import Cling
application = Cling(get_wsgi_application())
Any idea to fix it ?
What version of dj_static are you using?
I upgraded to Django 1.7 and my site broke, leading me to your question.
I checked my dj_static version (I had been using 0.0.5 and noticed that the latest release at the time of this writing is 0.0.6).
Upon updating dj_static, my site appears to be functioning properly under Django 1.7.