django-formset
django-formset copied to clipboard
Selectize filter-by bug
TL;DR:
- https://github.com/jrief/django-formset/issues/162#issuecomment-2323415707
- https://github.com/jrief/django-formset/issues/162#issuecomment-2334947241
Skip this (already identified as not the root cause)
Hi, Finally figured out the issue as to why Selectize filter-by functionality does not work in custom projects integrating django-formset library.
Note that this issue could not be replicated in the testapp for the investigation stated below.
I hope my explanation is clear. Please feel free to message me if it doesn't make sense
Issue:
- when installing django-formset==1.5 to custom projects, when I try to use Selectize filter-by, the functionality does not work
- when I try to use the testapp to replicate the issue, I could not report bug because Selectize filter-by works in testapp
How I discovered the issue:
- I followed the steps here so that I can investigate why Selectize filter-by is not working
- To my understanding, the flow for filter-by to function is:
- when app is run with a form that uses selectize widget, django-formset imports DjangoSelectize.js
- DjangoSelectize.js waits for select value to change, when triggered, will send fetch request for filtering
- FormView will receive fetch request, will process query, and return new select options back to frontend
- Using chrome browser dev-tools, I tried to understand which js files are triggered
- Running both test app and my custom project side by side, I compared and contrasted staticfiles being loaded in page.
- I found that the testapp DjangoSelectize-*.js filename differ from what is being used in my custom project
- I found that django-formset.js is the one importing what DjangoSelectize-*.js file will be used by the running django app
- I found that django-formset.js imports different DjangoSelectize-*js files when used in testapp and in custom proejct
- in testapp, it imports: DjangoSelectize-VSQ5POIH.js
- in custom project, it imports: DjangoSelectize-6XCBY3D6.js
- I tried to find why
DjangoSelectize-VSQ5POIH.jsis being imported in testapp, event thoughworkdir/static/formset/js/django-formset.jsimportsDjangoSelectize-6XCBY3D6.js - I found that testapp uses
formset/static/formset/js/django-formset.js
Conclusion and Summary:
- testapp selectize filter by works
- using selectize filter by in custom project do not work
- testapp and custom projects do not have the same django-formset.js files
- testapp uses
formset/static/formset/js/django-formset.jswhich importsDjangoSelectize-VSQ5POIH.js(successfully triggers fetch request) - custom projects uses similar to that located in
workdir/static/formset/js/django-formset.jswhich importsDjangoSelectize-6XCBY3D6.js(unsuccessful tigger fetch request)
My Workaround:
- right now I have to manually override
venv/lib/site-packages/.../formset/static/js/django-formset.jsto importDjangoSelectize-VSQ5POIH.js - it isn't nice. Lol. I have to be mindful of what I did. But works for the time being to make use of filter-by functionality.
Caveats:
- I have no knowledge with the differences for
DjangoSelectize-VSQ5POIH.jsandDjangoSelectize-6XCBY3D6.js - I also don't know which file is the most recent js file
- I just understand that django-formset.js only imports one
DjangoSelectize-*.jsfile so I assume that rather than these files work simultaneously, these are mutually exclusive / differ in versions