Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WagTail autocomplete for other models #108

Open
kokhoor opened this issue Apr 20, 2022 · 0 comments
Open

WagTail autocomplete for other models #108

kokhoor opened this issue Apr 20, 2022 · 0 comments

Comments

@kokhoor
Copy link

kokhoor commented Apr 20, 2022

Since when performing filter, the fieldname is either title or the autocomplete_search_field attribute, the render_page should be amended to add returning autocomplete values using autocomplete_search_field attribute of the record.

def render_page(page):
    if getattr(page, 'specific', None):
        # For support of non-Page models like Snippets.
        page = page.specific
    if callable(getattr(page, 'autocomplete_label', None)):
        title = page.autocomplete_label()
    elif getattr(page, 'autocomplete_search_field', None):  # added
        title = getattr(page, getattr(page, 'autocomplete_search_field', None))
    else:
        title = page.title
    return dict(pk=page.pk, title=title)
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

No branches or pull requests

1 participant