yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.79k stars 467 forks source link

How to set search/query field in GenericForeignKeyModelField? #1298

Open tylerecouture opened 2 years ago

tylerecouture commented 2 years ago

Is there a way to set the search field on a model when using the GenericForeignKeyModelField, similar to how you can with the Select2GenericForeignKeyModelField by passing a tuples to model_choices?

In a GenericForeignKeyModelField that second part of the tuple (the search field) gets ignored and still looks for a "name" field regardless.

Thanks!

jpic commented 1 year ago

I see copy and pasted code, but I don't use that at this time... meanwhile reviews are open for refactoring pull requests. I'm trying to refactor this from the ground up by generalizing the as_url() system, but I'm experimenting combining that with djhacker.formfield at the same time while we're at it so the whole chain is automated at once, in the spirit of DAL v2, but without the un-maintainable code I did naively at that time 10 years ago. Pushed to as_url branch but I'm not done there...