Skip to content

Conversation

@dchukhin
Copy link

Use Case:

The use case for this feature is a project using Django's default user model, with a Page that has a relation to the user model. Since Django's default user model does not have a title field, it's not possible to use wagtail-autocomplete on the relation. One option would be to define a custom user model and a title field, but doing so mid-project a difficult task. Instead, it would be great to be able to point the search to a different field on the model without having to edit the model.

Changes

This pull request:

  • updates the views.render_page() function to check (only if the page doesn't have an autocomplete_label attribute) for a WAGTAILAUTOCOMPLETE_CUSTOM_SEARCH_FIELD setting, and (if the setting is defined) to use the value of that setting.
  • updates the views.filter_queryset() function to check (only if the page doesn't have an autocomplete_search_field attribute) for a WAGTAILAUTOCOMPLETE_CUSTOM_FILTER_FIELDS setting, and (if the setting is defined) to use the value of that setting.
  • updates the documentation based on these changes

As a result, it is now possible to define which field(s) to use in the search without having to edit the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant