django-plotly-dash icon indicating copy to clipboard operation
django-plotly-dash copied to clipboard

TypeError in django-plotly-dash 1.6.1

Open fspreck-indiscale opened this issue 4 years ago • 5 comments

When upgrading from 1.6.0 to 1.6.1, I get the following TypeError when

[ERROR](django.request) 2021-02-17 08:17:23,010 Internal Server Error: /de/
Traceback (most recent call last):
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/core/handlers/base.py", line 145, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/core/handlers/base.py", line 143, in _get_response
    response = response.render()
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/response.py", line 83, in rendered_content
    content = template.render(context, self._request)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django/template/library.py", line 214, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django_plotly_dash/templatetags/plotly_dash.py", line 126, in plotly_direct
    resp = view_func()
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/django_plotly_dash/dash_wrapper.py", line 737, in index
    css = self._generate_css_dist_html()
  File "/home/fspreck_indiscale/.local/lib/python3.9/site-packages/dash/dash.py", line 642, in _generate_css_dist_html
    for link in (external_links + links)
TypeError: can only concatenate str (not "list") to str
[ERROR](django.server) 2021-02-17 08:17:23,011 "GET /de/ HTTP/1.1" 500 196550

Did the datatypes of links or external_links change from 1.6.0 to 1.6.1?

After downgrading to 1.6.0, everything works fine again.

fspreck-indiscale avatar Feb 17 '21 09:02 fspreck-indiscale

@fspreck-indiscale nothing in the test suite fails with 1.6.1 - are you able to share enough code to replicate the issue?

GibbsConsulting avatar Feb 24 '21 06:02 GibbsConsulting

Hi @GibbsConsulting, and thanks for the answer. I'll check whether I can boil it down to a minimal example.

fspreck-indiscale avatar Feb 25 '21 11:02 fspreck-indiscale

Any news on the issue, I am having the same bug with django-plotly-dash v1.6.6. ?

Peyo-Supp avatar Nov 21 '21 09:11 Peyo-Supp

@Peyo-Supp I think some sort of example that replicates the issue is needed

GibbsConsulting avatar Nov 21 '21 15:11 GibbsConsulting

I revisited the old project and found my mistake:

...
app = DjangoDash(
    ...
    external_stylesheets=[static("my.css")],  # Here, we really need a list in django-plotly-dash>1.6.0
    ...
)

In django-plotly-dash<=1.6.0, this would also work with a string in case of only one external style sheet. I couldn't find this in the changelog, though, so maybe you'll want to document this somewhere? In any case, I suppose this issue can be closed as resolved if this also works for @Peyo-Supp, can't it?

fspreck-indiscale avatar Apr 05 '22 07:04 fspreck-indiscale