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

Dependent field "country" value blank on drop down #275

Closed nameisnot closed 5 years ago

nameisnot commented 5 years ago

You MUST use this template when reporting issues. Please make sure you follow the checklist and fill in all of the information sections below.


All versions of django-smart-selects prior to version 1.2.8 are vulnerable to an XSS attack as detailed in issue 171. As a result, all previous versions have been removed from PyPI to prevent users from installing insecure versions. All users are urged to upgrade as soon as possible.

Checklist

Put an x in the bracket when you have completed each task, like this: [x]

Steps to reproduce

  1. Followed the instruction of usage (Continent, Country, Location models)
  2. Added USE_DJANGO_JQUERY = True in settings.py
  3. Added "path('chaining/', include('smart_selects.urls'))," to the app urls.py
  4. Using Admin to check the behavior (as demonstrated in the test app)

Actual behavior

  1. Getting "blank" field values for the country field (corresponding to the continent selected) with "show_all=False"
  2. With show_all=True, all values of the "country" is visible
  3. On changing the settings.py with "JQUERY_URL = True", getting ERROR: "bool' object has no attribute 'startswith' "

Expected behavior

  1. The "country" field values should correspond to the continent value picked up in the choice (drop down) widget.
nameisnot commented 5 years ago

Addendum: Using:

Python 3.6 Django 2.0.6 smart-selects 1.5.4

nameisnot commented 5 years ago

Problem solved (on Admin). What I did:

  1. Ran python3 manage.py collectstatic (from projects folder)

  2. Upgraded js-unlinting-fixes by running pip3 install --upgrade git+https://github.com/digi604/django-smart-selects.git@js-unlinting-fixes.

Note: I had missed the Step 1 first so even after installing the fix, the results was the same (no secondary key value)

  1. Refreshed browser cache.

PS. I have used USE_DJANGO_JQUERY = True in settings .py file.

Must say lots of fine minds at this site. Thankful to everyone for putting their thoughts which makes this a really great melting pot of ideas. The only need is to put everything at one place (after of course, resolution of an issue happens).

Closing the issue.

iserranoe commented 5 years ago

Thank you for the solution!! I really would have never managed to do it on my own. Just a question to try to understand the solution: why "python manage.py collectstatic" solves everything?