问题
I updated wagtail to the latest version 2.6.1 from 2.4 and noticed that the API call that fetches child pages for displaying in the ADMIN UI explorer now returns 0 pages.
admin/api/v2beta/pages/?child_of=1&for_explorer=1
{meta:
{total_count: 0},
items: [],
__types: {}}
items: []
meta: {total_count: 0}
total_count: 0
__types: {}
Is there anyway around this?
回答1:
This has been reported by a couple of other users on Wagtail 2.6 (see also Menu navigator disappeared after upgrading to Wagtail 2.6 (from 2.5)), but so far it hasn't been pinned down to a reproducible test case.
If you're seeing this bug on a local development build, and you're confident with git and pip
, then one thing that would be really useful for tracking this down would be to set up a local development copy of Wagtail 2.6 as per the documentation at https://docs.wagtail.io/en/stable/contributing/developing.html, and run git blame
over the stable/2.6.x
branch to find the commit that caused this bug. (Note that if you're just looking at the API output, you can safely skip the npm
build steps, as they're only needed for building the CSS/JS for the admin backend.)
I suspect https://github.com/wagtail/wagtail/commit/7c9c00ab7c791e69dc3476a7298783f875f00c21 (pull request #5069) may be the culprit, but it would be good to get confirmation.
回答2:
It appears that this can happen if your project has a custom value set for Django REST Framework's DEFAULT_AUTHENTICATION_CLASSES
setting. In this case, Wagtail's admin API will end up returning results based on the specified authentication method, rather than the current logged-in user.
https://github.com/wagtail/wagtail/issues/5585#issuecomment-543313909
To fix, add 'rest_framework.authentication.SessionAuthentication'
to your DEFAULT_AUTHENTICATION_CLASSES
setting. A new release 2.6.3 will likely be out in the next few days to address this.
来源:https://stackoverflow.com/questions/57825908/wagtail-admin-api-call-for-fetching-child-pages-returns-0-in-the-explorer