1๐
โ
I had to append the folder where all my apps lie to the PYTHONPATH environment variable like so:
PYTHONPATH="${PYTHONPATH}:/project_name/project_name"
๐คcalen
0๐
just like this. add a environment path to asgi.py
from channels.auth import AuthMiddlewareStack
import sys
sys.path.append('your-project-abspath')
import chat.routing
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'env.settings')
application = ProtocolTypeRouter(
{
"http":get_asgi_application(),
"websocket": AuthMiddlewareStack(
URLRouter(
chat.routing.websocket_urlpatterns
)
),
}
)
๐คLarge hare
- [Answered ]-Cassandra: occasional permission errors
- [Answered ]-Retrieve data from models having reverse relationship in django rest
- [Answered ]-How to query across generic relations in Django
- [Answered ]-How does Cygwin work for python programming?
- [Answered ]-Django orm โ annotate / aggregation (avg) in subquery
0๐
import os
import django
django.setup()
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from notification.routing import websocket_urlpatterns
from notification.utils.websocket_auth import WebSocketAuthMiddleware
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
application = ProtocolTypeRouter(
{
"http": get_asgi_application(),
"websocket": WebSocketAuthMiddleware(
URLRouter(websocket_urlpatterns)
),
}
)
In my case django setup fixed the problem.
just put django setup in asgi file.
๐คaoulaa
- [Answered ]-Django Q chained queries
- [Answered ]-Edit form in Django 1.6
- [Answered ]-Should I use two Postgres databases for Django on Heroku โ dev & prod?
- [Answered ]-Change template name for Django's auth views
Source:stackexchange.com