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

Ignore fields with __prefix__ in id

Open leibowitz opened this issue 4 years ago • 1 comments
trafficstars

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

leibowitz avatar Jun 15 '21 14:06 leibowitz

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.

codecov[bot] avatar Jun 15 '21 14:06 codecov[bot]