Put an x in the bracket when you have completed each task, like this: [x]
[ X] This issue is not about installing previous versions of django-smart-selects older than 1.2.8. I understand that previous versions are insecure and will not receive any support whatsoever.
[ X] I have verified that that issue exists against the master branch of django-smart-selects.
[ X] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
[ X] I have debugged the issue to the smart_selects app.
[ X] I have reduced the issue to the simplest possible case.
[ X] I have included all relevant sections of models.py, forms.py, and views.py with problems.
Have a formset with 2 smart selects, load the page
Actual behavior
Uncaught SyntaxError: Unexpected token _ in JSON at position 2 at JSON.parse (<anonymous>) at initItem (bindfields.js:8) at HTMLSelectElement.<anonymous> (bindfields.js:25) at Function.each (jquery-2.2.4.js:365) at HTMLDocument.<anonymous> (bindfields.js:24) at fire (jquery-2.2.4.js:3187) at Object.fireWith [as resolveWith] (jquery-2.2.4.js:3317) at Function.ready (jquery-2.2.4.js:3536) at HTMLDocument.completed (jquery-2.2.4.js:3552)
Expected behavior
No Javascript error occurs.
Suggested Fix:
The problem is that in widgets.py, ChainedSelect.render line 138 sets:
attrs["data-value"] = "null" if value is None or value == "" else value
So when the string "foo" is decoded, it fails with JSON decode error above (should be '"foo"' (with quotes))
I believe the fix should be:
attrs["data-value"] = "null" if value is None else json.dumps(value)
Which is the same as line 244 in ChainedSelectMultiple
Checklist
Put an
x
in the bracket when you have completed each task, like this:[x]
master
branch of django-smart-selects.smart_selects
app.models.py
,forms.py
, andviews.py
with problems.Steps to reproduce
Actual behavior
Uncaught SyntaxError: Unexpected token _ in JSON at position 2 at JSON.parse (<anonymous>) at initItem (bindfields.js:8) at HTMLSelectElement.<anonymous> (bindfields.js:25) at Function.each (jquery-2.2.4.js:365) at HTMLDocument.<anonymous> (bindfields.js:24) at fire (jquery-2.2.4.js:3187) at Object.fireWith [as resolveWith] (jquery-2.2.4.js:3317) at Function.ready (jquery-2.2.4.js:3536) at HTMLDocument.completed (jquery-2.2.4.js:3552)
Expected behavior
No Javascript error occurs.
Suggested Fix:
The problem is that in widgets.py, ChainedSelect.render line 138 sets:
attrs["data-value"] = "null" if value is None or value == "" else value
So when the string "foo" is decoded, it fails with JSON decode error above (should be '"foo"' (with quotes))
I believe the fix should be:
attrs["data-value"] = "null" if value is None else json.dumps(value)
Which is the same as line 244 in ChainedSelectMultiple