-
Notifications
You must be signed in to change notification settings - Fork 8
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
WagtailBackendSearchHandler ordering error with a Page descendant model #22
Comments
Hi @roodie - thanks for the report. Are you able to replicate this issue independently on a fresh Wagtail installation, please? That would assist us enormously in investigating this further. |
Sorry, yes, I was able, the sample code is actually from the fresh Wagtail installation and a separate small project. |
Hi @roodie. Does adding This is mostly why we couldn't make it the default option when objects are indexed using the search backend. Whenever a querystring is provided, the search backend needs to know how to parse the full query; including ordering and filters. By default, IndexView orders objects by the primary key (in this case You may be able to work around this by specifying an alternative default order via the the |
No, I still get the same error message (that was the first thing I tried when I encountered the error).
That would be perfectly okay, but setting the ordering Meta attribute (or the ordering property of the ModelAdmin) does not help. I checked the stacktrace, and it seems that the IndexView adds the '-page_ptr' order field even if I specify another field to be the default: ordering: ['date', 'date', '-page_ptr'] (The 'date' occurs twice here beause I set it in both the model's Meta and in the ModelAdmin subclass) |
Issue Summary
Due to some client requirement, I had to add a ModelAdmin for one of our custom Page types to our Wagtail-based site.
The class itself is very simple:
The date, is_sticky and is_on_index fields are added to she search_fields as filters.
The ModelAdmin page is similarly simple:
The search itself works properly; however, if I click on any of the field headers to sort a queryset, I get the following error:
It doesn't matter if I try to order by a specific NewsPage field, or ny the default Page.title for example.
Full strace:
Technical details
Python version: Python 3.6.8
Django version: 2.2.6
Wagtail version: 2..7
Search backend: Postgres (from contrib)
The text was updated successfully, but these errors were encountered: