Setting django_plotly_dash

Hello,
I am new here and I am learning to use plotly_dash in the Django application.
1st I have Django version 4.0.4.
I followed the installation guide to install django_plotly_dash as mentioned in the link:

https://django-plotly-dash.readthedocs.io/en/latest/installation.html

and also as the video below:
https://www.youtube.com/watch?v=psvU4zwO3Ao&list=PL5xgPYYRyWFk6AGGHdW_U7d9PMI-um_Ur&index=1

so in my settings.py, I add:

INSTALLED_APPS = [
‘django.contrib.admin’,
.
.
.
“django_plotly_dash.apps.DjangoPlotlyDashConfig”,
“channels”,
“channels-redis”
]
X_FRAME_OPTIONS = ‘SAMEORIGIN’
ASGI_APPLICATION = ‘WikiPED.routing.application’

  File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'channels-redis'

then I deleted channels-redis from INSTALLED_APPS and another error appears?

Django version 4.0.4, using settings 'WikiPed.settings'
Starting ASGI/Channels version 3.0.4 development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "D:\WikiPED\venv\lib\site-packages\channels\routing.py", line 28, in get_default_application
    module = importlib.import_module(path)
  File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'WikiPED'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "D:\WikiPED\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "D:\WikiPED\venv\lib\site-packages\channels\management\commands\runserver.py", line 107, in inner_run
    application=self.get_application(options),
  File "D:\WikiPED\venv\lib\site-packages\channels\management\commands\runserver.py", line 132, in get_application
    return StaticFilesWrapper(get_default_application())
  File "D:\WikiPED\venv\lib\site-packages\channels\routing.py", line 30, in get_default_application
    raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'WikiPED.routing'

Any solution
All my Best

It is unlikely that the current version of django-plotly-dash works with a Django version of 4.0 or greater. Can you use an older version of DJango, or is there a particular feature that you need?

I tried to downgrade the Django version to Django==4.0 and it doesn’t work
I re-installed the dash and django_plotly_dash

D:\WikiPED\WikiPed\settings.py changed, reloading.
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "D:\WikiPED\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "D:\WikiPED\venv\lib\site-packages\django\core\management\commands\runserver.py", line 115, in inner_run
    autoreload.raise_last_exception()
  File "D:\WikiPED\venv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "D:\WikiPED\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute
    autoreload.check_errors(django.setup)()
  File "D:\WikiPED\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "D:\WikiPED\venv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\WikiPED\venv\lib\site-packages\django\apps\registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "D:\WikiPED\venv\lib\site-packages\django\apps\config.py", line 223, in create
    import_module(entry)
  File "C:\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'channels-redis'

As I said, it is unlikely that Django version 4.0 or greater will work. Is there an obstacle to using an older version, such as 3.2 (which is the current LTS release)?

Nope but I just want to be up to date, I will try and it. However I installed Django 3.2 and the same problem appears?

and those are the requirements

aioredis==1.3.1
arabic-reshaper==2.1.3
asgiref==3.5.0
asn1crypto==1.5.1
async-timeout==4.0.2
attrs==21.4.0
autobahn==22.3.2
Automat==20.2.0
backports.csv==1.0.7
backports.zoneinfo==0.2.1
beautifulsoup4==4.11.1
bokeh==2.4.2
bootstrap4==0.1.0
branca==0.4.2
Brotli==1.0.9
certifi==2021.10.8
cffi==1.15.0
channels==3.0.4
channels-redis==3.2.0
chardet==4.0.0
charset-normalizer==2.0.12
click==8.1.2
colorama==0.4.4
constantly==15.1.0
cryptography==36.0.2
cssselect2==0.5.0
daphne==3.0.2
dash==2.3.1
dash-bootstrap-components==1.1.0
dash-core-components==2.0.0
dash-daq==0.5.0
dash-html-components==2.0.0
dash-renderer==1.9.1
dash-table==5.0.0
dataclasses==0.6
dbfread==2.0.7
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.13
diff-match-patch==20200713
dj-database-url==0.5.0
Django==3.2
django-ckeditor==6.3.2
django-crispy-forms==1.14.0
django-extensions==3.1.5
django-filter==21.1
django-forms-dynamic==1.0.0
django-heroku==0.3.1
django-htmx==1.9.0
django-import-export==2.8.0
django-js-asset==2.0.0
django-mathfilters==1.0.0
django-plotly-dash==1.6.6
django-redis==5.2.0
django-widget-tweaks==1.4.12
djangorestframework==3.13.1
dpd-components==0.1.0
dpd-static-support==0.0.5
et-xmlfile==1.1.0
Flask==2.1.1
Flask-Compress==1.11
folium==0.12.1.post1
future==0.18.2
geocoder==1.38.1
gunicorn==20.1.0
hiredis==2.0.0
html2pdf==0.1
html5lib==1.1
hyperlink==21.0.0
idna==3.3
importlib-metadata==4.11.3
incremental==21.3.0
itsdangerous==2.1.2
jdcal==1.4.1
Jinja2==3.1.1
lxml==4.8.0
MarkupPy==1.14
MarkupSafe==2.1.1
msgpack==1.0.3
numpy==1.22.3
oauthlib==3.2.0
odfpy==1.4.1
openpyxl==3.0.9
oscrypto==1.3.0
packaging==21.3
panda==0.3.1
pandas==1.4.2
patsy==0.5.2
Pillow==9.1.0
plotly==5.7.0
plotly-express==0.4.1
psycopg2==2.9.3
psycopg2-binary==2.9.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pyHanko==0.12.1
pyhanko-certvalidator==0.19.5
PyJWT==2.3.0
pyOpenSSL==22.0.0
pyparsing==3.0.8
PyPDF2==1.27.4
PyPDF3==1.0.6
python-bidi==0.4.2
python-dateutil==2.8.2
python-decouple==3.6
python3-openid==3.2.0
pytz==2022.1
pytz-deprecation-shim==0.1.0.post0
PyYAML==6.0
qrcode==7.3.1
ratelim==0.1.6
redis==4.2.2
reportlab==3.6.9
requests==2.27.1
requests-oauthlib==1.3.1
scipy==1.8.0
service-identity==21.1.0
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.2
statsmodels==0.13.2
svglib==1.2.1
tablib==3.2.1
tenacity==8.0.1
tinycss2==1.1.1
tornado==6.1
tqdm==4.64.0
Twisted==22.4.0
twisted-iocpsupport==1.0.2
txaio==22.2.1
typing==3.7.4.3
typing-extensions==4.1.1
tzdata==2022.1
tzlocal==4.2
uritools==4.0.0
urllib3==1.26.9
waitress==2.1.1
webencodings==0.5.1
Werkzeug==2.0.3
whitenoise==6.0.0
wrapt==1.14.0
xhtml2pdf==0.2.7
xlrd==2.0.1
xlwt==1.3.0
zipp==3.8.0
zope.interface==5.4.0

django-plotly-dash v1.6.6 should require a dash version < 1.21

Is this not being enforced during installation, or a warning given?

No, no message appears, and I tried to install it according to this tuto:

https://thinkinfi.com/integrate-plotly-dash-in-django/

and I created a file named routing.py

#routing.py
from django_plotly_dash.routing import application

and the server starts with this error!

April 18, 2022 - 20:03:14
Django version 3.2, using settings 'WikiPed.settings'
Starting ASGI/Channels version 3.0.4 development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Exception inside application: __init__() takes 1 positional argument but 2 were given
Traceback (most recent call last):
  File "D:\WikiPED\venv\lib\site-packages\channels\staticfiles.py", line 44, in __call__
    return await self.application(scope, receive, send)
  File "D:\WikiPED\venv\lib\site-packages\channels\routing.py", line 71, in __call__
    return await application(scope, receive, send)
  File "D:\WikiPED\venv\lib\site-packages\channels\sessions.py", line 47, in __call__
    return await self.inner(dict(scope, cookies=cookies), receive, send)
  File "D:\WikiPED\venv\lib\site-packages\channels\sessions.py", line 263, in __call__
    return await self.inner(wrapper.scope, receive, wrapper.send)
  File "D:\WikiPED\venv\lib\site-packages\channels\auth.py", line 185, in __call__
    return await super().__call__(scope, receive, send)
  File "D:\WikiPED\venv\lib\site-packages\channels\middleware.py", line 26, in __call__
    return await self.inner(scope, receive, send)
  File "D:\WikiPED\venv\lib\site-packages\channels\routing.py", line 150, in __call__
    return await application(
  File "D:\WikiPED\venv\lib\site-packages\asgiref\compatibility.py", line 33, in new_application
    instance = application(scope)
TypeError: __init__() takes 1 positional argument but 2 were given
HTTP GET /datavis/ 500 [0.59, 127.0.0.1:55675]

Are you able to share how you did the installation?

I can’t find a way to install django-plotly-dash and also a version of dash > 1.20 without having to force install or upgrade one of them, and when I do I get a warning telling me the versions are incompatible.

I’d spent hours changing my packages versions till it works!

So as a conclusion:

The main packages are (Django and channels )
I tested again all versions from Django==4.0.4 to 2.2.28
and for every Channels version till it works.

so the working versions are Django==2.2.28 and channels==2.4.0