carltongibson / django-filter

A generic system for filtering Django QuerySets based on user selections
https://django-filter.readthedocs.io/en/main/
Other
4.41k stars 766 forks source link

Remove hardcode of rest_framework crispy form template_pack #1564

Closed bckohan closed 1 year ago

bckohan commented 1 year ago

Fixes #1537.

The template_pack is hardcoded to 'bootstrap3' in rest_framework's FilterSet. This change simply removes the setter allowing crispy forms to determine what the template pack should be based on the crispy forms configuration or whichever the default pack is for the installed version of crispy forms.

The Layout objects used are generic and should be compatible with any template pack, but as before if users want to customize the crispy form they can override the form property.

This change is necessary because some template packs step on each other. In this case bootstrap3 and bootstrap5 are incompatible. Simply installing the bootstrap5 template pack is enough to crash browsable DRF rendering.

codecov-commenter commented 1 year ago

Codecov Report

Merging #1564 (7a60ea1) into main (20ca22a) will decrease coverage by 0.01%. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1564      +/-   ##
==========================================
- Coverage   99.44%   99.44%   -0.01%     
==========================================
  Files          15       15              
  Lines        1259     1258       -1     
==========================================
- Hits         1252     1251       -1     
  Misses          7        7              
Impacted Files Coverage Δ
django_filters/rest_framework/filterset.py 100.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.