[Django]-Cannot import ASGI_APPLICATION module 'myproject.routing'

1๐Ÿ‘

โœ…

Iโ€™ve solved the error, i was using the version 3.0.dev20190127224143 of django, and i solved doing the roll back to the version 2.1.7

5๐Ÿ‘

You need to add this line to settings.py file.

ASGI_APPLICATION = "routing.application"

found here: Cannot import ASGI_APPLICATION module while runserver using channels 2

๐Ÿ‘คDiogo Rosa

2๐Ÿ‘

  1. put the routing.py in the same level as settings.py.

  2. Ensure there is no error in routing.py. You can check it by replacing the content with

    from channels.routing import ProtocolTypeRouter

    application = ProtocolTypeRouter({
    })

and see if it solves.

๐Ÿ‘คrjhcnf

1๐Ÿ‘

I have same error because i wrote consumer.py instead of consumers.py by mistake. Then I renamed it to consumers.py and error solved.

๐Ÿ‘คRasim Mammadov

0๐Ÿ‘

I had same issue because I wrote a class name in imports of asgi.py file that wasnโ€™t defined. Then I removed that undefined class of authentication and the error was fixed.

Please check your defined imports in asgi.py file.

๐Ÿ‘คArti

0๐Ÿ‘

for myself it was beacuse of a missing package called
whitenoise, after installing via pip everything worked fine

pip install whitenoise

๐Ÿ‘คAvin Mathew

0๐Ÿ‘

I solved it changing my version of Django from 4.0.5 to 3.2.5; see: https://docs.djangoproject.com/en/4.0/releases/3.2.5/

๐Ÿ‘คMarcus Mora

0๐Ÿ‘

It helps to me to mark a directory as a source root in Pycharm

๐Ÿ‘คJu Chi

Leave a comment