-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Error with django-compressor: ValueError: dictionary update sequence element #0 has length 5; 2 is required
#414
Comments
ValueError: dictionary update sequence element #0 has length 5; 2 is required
Related discussion with the same error: #411 |
In component.Component.render we wrap context_data in Context(). Could that be the root cause? It was added in this commit 91b4acc#diff-569e56c0c056d2ede4e534ad3cae3717ff8e61ba7fdd6963a23df1adc8fd86d1R150 when we added support for rendering component as views. |
I was thinking of that too (not wrapping the |
Ok, so the issue was with See #415 |
Setup
settings.py
template.html
Full trace
What I've learnt so far:
It seems like this issue is between django-compressor and django-components media dependencies. Because when I remove either of the two, the issue resolves:
a) remove
compress
block:b) remove
component_css_dependencies
block:The issue relates to the Django's
Context
class. The actual error occurs in Django, when it callsContext.flatten
. My understanding is that one of the dicts incontext
is actually a nestedContext
instance, and Django cannot work with that, it expects plain dicts.Workaround - I wasn't able to find out what's the root cause, but I was able to find 2 ways to resolve this issue:
a. Resolve nested Contexts on
django
's side in django/template/context.py(Note: my issue is in django v4.2, but in v5.0, the
flaten
function is the same)b. Resolve nested Contexts on
django-component
's side in django-components/component.pyConclusion:
I'd rather fix the underlying cause, if someone knows what it might be, please help. But if we won't be able to get to the root of it, we can deploy a quick workaround on
django-components
's side.The text was updated successfully, but these errors were encountered: