Reputation: 129
I need to make fields with autocomplete for my custom forms. It's just a drop-down menu with matched cities, countries etc. I also use django-cities for that. So, I subclassed AutocompleteModelBase. Here, I can declare search_fields attribute with list of fields from model, on which the search will be applied. But what if I want to search not by the fields, but by, for example, info from related managers? In django-cities, there is special related manager for so-called alternative names. It returns queryset with names for some geo object in
foreign languages. Something like this: Country.objects.get(code='US').alt_names.filter(language='de')
So, I need to search by the results of such operations. Not by the fields of the model, but by translated names, which don't belong to actually fields. Thanks.
Upvotes: 1
Views: 159