django-smart-selects icon indicating copy to clipboard operation
django-smart-selects copied to clipboard

Not working if primary key value of related object is 0 (zero)

Open lorenzomorandini opened this issue 3 years ago • 1 comments

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]

  • [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.

Steps to reproduce

  1. Create a model A with an integer primary key and create an instance of it with pk = 0 (zero)
  2. Create a model B with a chained foreign key to model A
  3. In admin create an instance of model B, selecting the instance with pk = 0 of model A

Actual behavior

Model B saves successfully but on opening it again the select appear empty.

Expected behavior

Select should show the saved instance of model A.

Possibly related to issue #326 (not sure tho).

lorenzomorandini avatar May 27 '21 14:05 lorenzomorandini

Has anybody found a solution for this? My forms are working properly for all entries were the primary key value of related object is > 0, but 0 nothing shows... Thanks

faivala-de avatar Sep 24 '22 13:09 faivala-de