我开发了一个鹡鸰网站,效果很好。这只是一个简单的博客。我能够在其下添加博客索引页和博客文章。最近将鼠标悬停在尝试添加新页面时会出现错误
PathOverflow at /admin/pages/add/blog/blogpage/8/
以下是完整的回溯。
Environment:
Request Method: POST
Request URL: https://vikatakavi.info/admin/pages/add/blog/blogpage/8/
Django Version: 2.1.5
Python Version: 3.5.2
Installed Applications:
['home',
'search',
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'blog']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware']
Traceback:
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/wagtail/admin/urls/__init__.py" in wrapper
102. return view_func(request, *args, **kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/wagtail/admin/decorators.py" in decorated_view
34. return view_func(request, *args, **kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/wagtail/admin/views/pages.py" in create
224. parent_page.add_child(instance=page)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/treebeard/mp_tree.py" in add_child
1013. return MP_AddChildHandler(self, **kwargs).process()
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/treebeard/mp_tree.py" in process
387. newobj.path = self.node.get_last_child()._inc_path()
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/treebeard/mp_tree.py" in _inc_path
1114. raise PathOverflow(_("Path Overflow from: '%s'" % (self.path, )))
Exception Type: PathOverflow at /admin/pages/add/blog/blogpage/8/
Exception Value: Path Overflow from: '000100010005ZZZZ'
我对此一无所知。
为了存储页面在页面树中的位置,Wagtail 使用了一种称为“物化路径”的技术,该技术(在其标准设置中)允许在树中的特定点最多插入 1679615 次。看来你已经达到了这个极限。 (树中每个点的位置都表示为 4 个字符的字母数字代码;错误消息中看到的“ZZZZ”是最高的可用代码。) 如果您拥有超过 160 万篇博客文章,您就会遇到此限制,但显然这不太可能。更可能的可能性是您编写了一个执行大量插入或页面移动的导入或维护脚本 - 例如,如果您有一个随机重新排序页面的脚本,并且您在包含 10000 个页面的部分上运行它页,运行大约 160 次后,您将耗尽索引号。
如果您确实无法避免达到此限制,那么您可以通过在启动时运行的位置添加以下代码来将限制增加到 6000 万:
from wagtail.core.models import Page
Page.steplen = 5
但是,这不适用于现有数据库 - 进行此更改后,您需要删除并重新创建数据库 - 这意味着树的最大可能深度从 63 层减少到 50 层。
class MyAppConfig(AppConfig)
以及迁移中尝试过这个。 @gasman,你能解释一下它应该在何时何地执行吗?