Skip to content

Add warning regarding title field in index#75

Open
fabienheureux wants to merge 2 commits intowagtail:mainfrom
fabienheureux:add-warning-regarding-title-field-for-postgres
Open

Add warning regarding title field in index#75
fabienheureux wants to merge 2 commits intowagtail:mainfrom
fabienheureux:add-warning-regarding-title-field-for-postgres

Conversation

@fabienheureux
Copy link
Copy Markdown
Member

Add W005 warning when SearchField("title") is missing

Summary

I noticed (accidentally) that title field name is special in Django ModelSearch: a SearchField named "title" populates a dedicated title index column used for ranking. If no such field is declared, the title column is silently left empty, degrading search quality with no indication to the developer.

This PR adds a system check warning (modelsearch.W005) that fires when a model defines at least one SearchField but none of them is named "title".

I think this is a wagtail's legacy where title is always defined

Example warning output

myapp.Article: (modelsearch.W005) Article.search_fields does not contain a SearchField named 'title'. The title index column will be empty.
    HINT: Add index.SearchField('title') to Article.search_fields to populate the title index column, which is used for ranking search results.

@fabienheureux fabienheureux force-pushed the add-warning-regarding-title-field-for-postgres branch from 175ae76 to 9118988 Compare March 26, 2026 11:54
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