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
Related
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
flask-mega-tutorial and I found some error when I execute my code.
first I have init.py
from flask import Flask
app = Flask(__name__)
from app import routes
then routes.py
from app import app
#app.route('/')
#app.route('/index')
def index():
return "Hello, World!"
And last I have microblog.py to execute my code
from app import app
app.run(debug=True)
but when I execute FLASK_APP = microblog.py then flask run, I found this
Serving Flask app "microblog.py"
Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
Debug mode: off Usage: flask run [OPTIONS]
Error: While importing "microblog", an ImportError was raised:
Traceback (most recent call last): File
"e:\skripsiku\flask\lib\site-packages\flask\cli.py", line 235, in
locate_app import(module_name) File "E:\skripsiku\microblog.py",
line 1, in from app import app ImportError: cannot import
name 'app'
Oh and lastly there is my folder structure. I have main folder named skripsiku then in there I have app folder (in : init.py, routes.py) and microblog.py. Can anyone help me? thank you
try this:
from app import app as appl
you can use any name in place of appl
The directory for that tutorial is
minus the pycache and .vscode.
According to the tutorial, FLASK_APP=fua.py or microblog.py in your case.
I am assuming that you did flask run in the C:\xampp\htdocs\FUA App\app> directory since I faced a similar error when running that command from that directory.
I solved the problem by running the command from the C:\xampp\htdocs\FUA App.
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)
Since the project is evolving I would like to start executing the system check framework of Django on dev environment. The technology stack is Ubuntu, PostgreSQL, Django1.9 + UWSGI. But...
django-admin check
outputs the following error:
ImportError: No module named my_project.settings
The wsgi.py file contains:
import os
import sys
from django.core.wsgi import get_wsgi_application
sys.path.append('~/virtenv/my_site')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_site.settings")
application = get_wsgi_application()
The env variable DJANGO_SETTINGS_MODULE echoes my_site.settings
It is important to mention that the settings.py file is in virtenv/my_site/my_site/ . Please also note that the entire web application is running fine, I am also using the features of manage.py. Its just the django-admin check that is getting on my nerves.
you seem to append to the sys path in the wsgi but the admin check won't be using that.
Make sure you add the project path to the sys path for the environment you're using
I'm using Virtualenv wrapper and having issues to runserver.
The full error:
django.core.exceptions.ImproperlyConfigured: WSGI application 'myproject.wsgi.application' could not be loaded; could not import module 'myproject.wsgi': No module named wsgi
I have the file wsgi.py at settings.py`s directory.
Anyone can help me?
I was looking to my application's behavion and my local_settings.py is not being imported to, can be some misconfiguration?
Thanks!