Wagtail Admin api call for fetching child pages returns 0 in the explorer

≡放荡痞女 提交于 2019-12-24 17:48:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!