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

Ignore fields with __prefix__ in id #332

Open leibowitz opened 3 years ago

leibowitz commented 3 years ago

django-smart-selects is currently initialising fields that aren't displayed on screen (including __prefix__ in the id) https://docs.djangoproject.com/en/3.2/topics/forms/formsets/#empty-form

These are usually created for one/many-to-many relationships, and are cloned when a user clicks on the "add another" within the admin. The __prefix__ is then replaced with an index number (starting at 0)

There is a lot of code spread around to skip fields that include __prefix__: https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/contrib/admin/static/admin/js/SelectFilter2.js#L11-L14 https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/contrib/admin/static/admin/js/autocomplete.js#L33

codecov[bot] commented 3 years ago

Codecov Report

Merging #332 (ed45b07) into master (2cff847) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #332   +/-   ##
=======================================
  Coverage   80.42%   80.42%           
=======================================
  Files           8        8           
  Lines         470      470           
  Branches       68       68           
=======================================
  Hits          378      378           
  Misses         60       60           
  Partials       32       32           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2cff847...ed45b07. Read the comment docs.