简体   繁体   English

不能再在鹡鸰中保存页面

[英]can not save pages any more in wagtail

when clicking publish or save draft I got this error wagtail.core.models.Page.DoesNotExist: Page matching query does not exist.单击发布或保存草稿时,我收到此错误wagtail.core.models.Page.DoesNotExist: Page matching query does not exist. this happens only with old pages, the newly created pages are being able to be created and saved without any errors这只发生在旧页面上,新创建的页面能够被创建和保存而不会出现任何错误

NB: the new pages do not have children pages yet trying to find out what is causing this error despite I did not override the save method any suggestion or hint will be very helpful thank you注意:尽管我没有覆盖保存方法,但新页面没有子页面但试图找出导致此错误的原因任何建议或提示都会非常有帮助谢谢

here the traceback:这里是追溯:

wagtail.core.models.DoesNotExist
wagtail.core.models.Page.DoesNotExist: Page matching query does not exist.

Traceback (most recent call last)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/contrib/staticfiles/handlers.py", line 76, in __call__
return self.application(environ, start_response)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
response = self.get_response(request)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/base.py", line 130, in get_response
response = self._middleware_chain(request)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/exception.py", line 49, in inner
response = response_for_exception(request, exc)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/exception.py", line 103, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/exception.py", line 138, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/admin/urls/__init__.py", line 127, in wrapper
return view_func(request, *args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/admin/auth.py", line 172, in decorated_view
response = view_func(request, *args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/admin/views/pages/edit.py", line 131, in dispatch
return super().dispatch(request)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/admin/views/pages/edit.py", line 218, in post
return self.form_valid(self.form)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/admin/views/pages/edit.py", line 238, in form_valid
return self.publish_action()
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/admin/views/pages/edit.py", line 286, in publish_action
revision.publish(
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/core/models.py", line 2972, in publish
page.save()
File "/home/oladhari/gounite-v2/GOunite/v2/home/models.py", line 98, in save
super().save(*args, **kwargs)
File "/usr/lib/python3.8/contextlib.py", line 75, in inner
return func(*args, **kwds)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/core/models.py", line 1028, in save
result = super().save(**kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/modelcluster/models.py", line 199, in save
getattr(self, relation).commit()
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/modelcluster/fields.py", line 202, in commit
item.delete()
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/wagtail/core/models.py", line 1094, in delete
return Page.objects.get(id=self.id).delete(*args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/oladhari/.virtualenvs/gounite/lib/python3.8/site-packages/django/db/models/query.py", line 429, in get
raise self.model.DoesNotExist(
wagtail.core.models.Page.DoesNotExist: Page matching query does not exist.

The part that is throwing errors looks like code in your models that relates one page to other pages.引发错误的部分看起来像是模型中将一页与其他页相关联的代码。 See this line: return Page.objects.get(id=self.id).delete(*args, **kwargs) ?看到这一行: return Page.objects.get(id=self.id).delete(*args, **kwargs) So I think we need to know what "items" are and how the page you are saving uses them.所以我认为我们需要知道什么是“项目”以及您保存的页面如何使用它们。

Please post the models for the page you are saving and the pages that are referenced as 'items'请发布您正在保存的页面的模型以及被引用为“项目”的页面

Finally resolved it we should not use ParentalKey with a Page model (we were using it in GOPart model which is a Page model, changing it to ForeignKey resolved the error and now we can save the HomePage终于解决了,我们不应该将 ParentalKey 与页面 model 一起使用(我们在 GOPart model 中使用它,这是一个页面 model,将其更改为 HomePage 我们现在可以保存错误)

class MyModel(RoutablePageMixin, Page, Orderable):

    parent_page_types: list = []

    company = ParentalKey(
        "home.HomePage",
        on_delete=models.SET_NULL,
        verbose_name=_("Company"),
        null=True,
        blank=False,
    )

changing it to:将其更改为:

class MyModel(RoutablePageMixin, Page):

    parent_page_types: list = []

    company = models.ForeignKey(
        "home.HomePage",
        on_delete=models.SET_NULL,
        verbose_name=_("Company"),
        null=True,
        blank=False,
    )

a Page can not be Orderable页面不能订购

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM