Open vs06 opened 7 years ago
What's the JSON that's erroring out?
+1 is there some solutions?
@vs06 there are several inlines in the test-app that are working correctly. We need more details on how to reproduce, ideally using the test-app. And also the JSON response would help here.
To reproduce this, you just need to save the model and try to change it again. I have asked a question on StackOverflow. I don't know if it's relevant but I see a very similar error message on the console.
@Asocia yes please, paste any JS error you get. Are you using the latest version?
Here is the error message:
Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
initItem http://127.0.0.1:8000/static/smart-selects/admin/js/bindfields.js:8
<anonymous> http://127.0.0.1:8000/static/smart-selects/admin/js/bindfields.js:36
each jQuery
<anonymous> http://127.0.0.1:8000/static/smart-selects/admin/js/bindfields.js:35
jQuery 4
i
fireWith
ready
J
bindfields.js:8:26
initItem http://127.0.0.1:8000/static/smart-selects/admin/js/bindfields.js:8
<anonymous> http://127.0.0.1:8000/static/smart-selects/admin/js/bindfields.js:36
each jQuery
<anonymous> http://127.0.0.1:8000/static/smart-selects/admin/js/bindfields.js:35
jQuery 4
i
fireWith
ready
J
Here is the output of pip freeze | grep smart
:
django-smart-selects==1.5.9
Great, now if you could only check the "Network" tab when this happens, to see the contents of the response, as it seems there is something wrong there.
Nothing seems to wrong to me. Can you tell exactly which information you need?
Edit: I think I found something. I will share it soon.
As per your Stack Overflow description: "... when I change faculty from 1 to 2 dropdown for the programs are not updated ..."
Clean your network tab so you see no requests. Change Faculty from 1 to 2. At this point you should see a request in the network tab. We need to know what the content of this request is.
I think I found something. I will share it soon.
The syntax highlighting in the response was broken after some point like this:
So I thought there are some characters that is causing the problem. However, when I copy and format those lines, everything looks normal for me:
<div id="div_id_faculty" class="form-group">
<label for="id_faculty" class=" requiredField">
Faculty<span class="asteriskField">*</span> </label>
<div class="">
<select name="faculty" class="select form-control" required id="id_faculty">
<option value="">---------</option>
<option value="IN" selected>IN - İnşaat Fakültesi</option>
<option value="MM">MM - Mimarlık Fakültesi</option>
<option value="MK">MK - Makina Fakültesi</option>
<option value="EE">EE - Elektrik - Elektronik Fakültesi</option>
<option value="MD">MD - Maden Fakültesi</option>
<option value="KM">KM - Kimya - Metalurji Fakültesi</option>
<option value="IS">IS - İşletme Fakültesi</option>
<option value="GD">GD - Gemi İnşaatı ve Deniz Bilimleri Fakültesi</option>
<option value="FE">FE - Fen - Edebiyat Fakültesi</option>
<option value="UU">UU - Uçak ve Uzay Bilimleri Fakültesi</option>
<option value="KO">KO - Türk Musikisi Devlet Konservatuarı</option>
<option value="DZ">DZ - Denizcilik Fakültesi</option>
<option value="TK">TK - Tekstil Teknolojileri ve Tasarımı Fakültesi</option>
<option value="BB">BB - Bilgisayar ve Bilişim Fakültesi</option>
<option value="SN">SN - Uluslararası Ortak Lisans Programları</option>
<option value="KK">KK - İTÜ Kuzey Kıbrıs</option>
</select>
</div>
</div>
<div id="div_id_program" class="form-group">
<label for="id_program" class=" requiredField">
Program<span class="asteriskField">*</span> </label>
<div class="">
<select name="program" class="chainedselect form-control chained-fk" required id="id_program" data-chainfield="faculty" data-url="/chaining/filter/sis/Program/faculty/students/Student/program" data-value="BLGE" data-auto_choose="false" data-empty_label="--------" name="program">
<option value="">--------</option>
<option value="BLG">BB faculty's BLG program.</option>
<option value="BLGE" selected>BB faculty's BLGE program.</option>
<option value="YZVE">BB faculty's YZVE program.</option>
</select>
</div>
</div>
Clean your network tab so you see no requests. Change Faculty from 1 to 2. At this point you should see a request in the network tab.
No request happens when I do this.
@Asocia after looking at the html you pasted and noticed that you are not using integers for your Primary Keys, which is currently unsupported by smart-selects.
I got it. It would be nice if this was documented. Anyways, thanks for your time.
How did you fix it?
AFAIK, integer Primary Keys are still required
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
I use Django Smart Selects to dynamically choose a document based on its document type. It work fine on an Admin Page, but I have another Page with an Inline Admin and there I've got this error:
MyClass model:
MyClass admin inline: