jazzband / django-smart-selects

chained and grouped selects for django forms
https://django-smart-selects.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.1k stars 348 forks source link

ChainedForeignKey empty_label can not be changed #319

Open wongfl opened 3 years ago

wongfl commented 3 years ago

Checklist Put an x in the bracket when you have completed each task, like this: [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. [x]I have used GitHub Flavored Markdown to style all of my posted code.

I have the same issue. the first empty label has been changed to ' Select Cateogory' from the django default '------' .

But on the second select field (i.e the ChainedForeignKey in the model) , the empty_label is still showing the django default '----'

Please assists !!!

self.fields['category'].empty_label = 'SELECT CATEGORY' <--- works self.fields['subcategory'].empty_label = 'SELECT CATEGORY' <--- Does not work

any solutions to this?

Originally posted by @xhaxhi in https://github.com/jazzband/django-smart-selects/issues/236#issuecomment-583895683

NorDULaN commented 3 years ago

Check the foreign key models.py for the absence of "to-field = yourchoose,". Smart-selects only works with a pointer: / chaining / filter / app / model / field / field_id / fieldwhereyoucreate / field / yourvalue / yourvalue = id of the parent subcategory. It took me 3 hours to figure it out. It would be nice to add all (part) your models.py code here.