Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using asgi server such as daphne error #99

Open
kimutaiRop opened this issue Jan 29, 2023 · 1 comment
Open

using asgi server such as daphne error #99

kimutaiRop opened this issue Jan 29, 2023 · 1 comment

Comments

@kimutaiRop
Copy link

kimutaiRop commented Jan 29, 2023

I have been tryign to use asgi server to run websocket in production and kept gettign error. wen though the example and that is when I realized that this could be issue with the way the asgi application is set, Is it all right the way schema is loaded before the django application is mounted?

tried this daphne example:application -b 0.0.0.0 -p 8000 command in example directory and it is falling.
Django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I dont know coz I dont see such issue maybe someone know how I can run production asgi server or that just people using django runserver in production

@kimutaiRop
Copy link
Author

kimutaiRop commented Jan 29, 2023

ok just weird posted this and instatly was able to solve this by adding

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
import django
django.setup()

ontop of the all example.py file as same applied to my server but I think it is a good idea to include such in the example file for easy reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant