Heroku sais: "Requested setting LOGGING_CONFIG" but it is set? - python

I'm trying to setup a Django site on Heroku. I get this error message:
2017-10-07T21:03:33.416585+00:00 app[web.1]:
django.core.exceptions.ImproperlyConfigured: Requested setting
LOGGING_CONFIG, but settings are not configured. You must either define
the environment variable DJANGO_SETTINGS_MODULE or call
settings.configure() before accessing settings.
But if I run Heroku config, the var is set. Why is it not recognized?
=== dagenssalg Config Vars
DISABLE_COLLECTSTATIC: 0
LOGGING_CONFIG: off
Many answers in here mention the wsgi.py file, but I can't see anything wrong with that:
import os
from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings")
application = get_wsgi_application()
Any help is most appreciated. Best regards Kresten

Your wsgi file is a mess. You import get_wsgi_application twice, then call it before setting the environment variable; you then correctly wrap the application instance with WhiteNoise, but then throw away this instance by calling get_wsgi_application again.
Replace the whole thing with this:
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)

Related

Error running WSGI application in Pythonanywhere

I have researched a lot and found this is a very common question. But the fact is I believe somehow pythonanywhere can not detect my settings.py file. Moreover, I have checked with the settings file directory and it is the same path as I have input in the WSGI file. I have also installed the required pip files but still getting the same errors.
Error running WSGI application
ModuleNotFoundError: No module named 'widget_tweaks'
File "/var/www/ewallet_pythonanywhere_com_wsgi.py", line 33, in <module>
application = get_wsgi_application()
File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
Here is the wsgi.py
import os
import sys
path = '/home/ewallet/E-wallet/ewallet/ewallet/'
if path not in sys.path:
sys.path.append(path)
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'ewallet.settings'
application = get_wsgi_application()
Here is the directory image
Kindly help me to find the bug here. Thank you
You just entered path incorrectly. It should be as following:
path = '/home/ewallet/E-wallet/ewallet
So, correct version of your wsgi.py is as following:
import os
import sys
path = '/home/ewallet/E-wallet/ewallet/ewallet/'
if path not in sys.path:
sys.path.append(path)
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'ewallet.settings'
application = get_wsgi_application()

getting Error running WSGI application NameError: while i deployed my DJango app to pythonanywhere?

Complete error
2021-09-18 10:35:44,065: Error running WSGI application
2021-09-18 10:35:44,068: NameError: name 'get_wsgi_application' is not defined
2021-09-18 10:35:44,068: File "/var/www/dhruv354_pythonanywhere_com_wsgi.py", line 30, in <module>
2021-09-18 10:35:44,068: application = get_wsgi_application()
my wsgi.py file
import os
import sys
path = '/home/dhruv354/Django-grocery/'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'ReadingRight.settings'
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(get_wsgi_application())
Everything seems fine to me but still it is giving this error, needs help

pythonanywhere:Error code: Unhandled Exception

hi guys.when tried deploy my django site with pythonanywhere i get an error:
here my WSGI configuration file:/var/www/cargoglobal_pythonanywhere_com_wsgi.py:
import os
import sys
path = '/home/cargoglobal/CargoGlobal.net'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'elansayti.settings'
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(get_wsgi_application())
and here my projects wsgi.py:
"""
WSGI config for elansayti project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'elansayti.settings')
application = get_wsgi_application()
please help me guys.i am a very helpless.

ModuleNotFoundError: No module named 'heroku'

I have searched a lot regarding uploading my django project on heroku but I'm unable to do that. Please check the following structure and let me know what is wrong and why I'm getting this error:
File "/app/djangosample1/settings.py", line 17, in
import heroku as heroku
ModuleNotFoundError: No module named 'heroku'
Structure of my project:
https://github.com/cabudies/djangosample2-master/blob/master/structure.png
Procfile
web: gunicorn djangosample1.wsgi --log-file-
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangosample1.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
Also, whenever I'm running 'python manage.py runserver' even on local server, I'm getting error:
SyntaxError: invalid syntax at heroku\helpers.py

No module named django.core.wsgi with nginx, uwsgi and virtualenv

uwsgi.ini
[uwsgi]
vhost = true
plugin = python
socket = /tmp/pjwards.sock
master = true
enable-threads = true
processes = 2
wsgi-file = /home/ubuntu/workspace/ward/www/fb_archive/wsgi.py
virtualenv = /home/ubuntu/.virtualenvs/fb_archive
chdir = /home/ubuntu/workspace/ward/www/fb_archive
touch-reload = /home/ubuntu/workspace/ward/www/reload
wsgi.py
import site
import os
import sys
from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name
site.addsitedir('/home/ubuntu/.virtualenvs/fb_archive/lib/python3.4/site-packages')
sys.path.insert(0, '/home/ubuntu/workspace/ward')
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"%s.settings" % real_project_name("fb_archive"))
application = get_wsgi_application()
uWSGI does not work by ImportError: No module named django.core.wsgi.
I use nginx, uwsgi and virtualenv with python3.
Traceback (most recent call last):
File "/home/ubuntu/workspace/ward/www/fb_archive/wsgi.py", line 13, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
You're doing the import before you've added your virtualenv to the pythonpath, so naturally the module can't be found. Move the import to just before the get_wsgi_application() call itself.

Categories