Всем привет! Пытаюсь сделать пример из документации по wagtail cms но получаю ошибку:
django.core.exceptions.FieldError: Cannot resolve keyword 'order' into field. Choices are: catalogindexpage, catalogpage, content_type
код моей модели:
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.search import index
class CatalogIndexPage(Page):
intro = RichTextField(blank=True)
order = models.IntegerField('Порядок')
def get_context(self, request, *args, **kwargs):
context = super().get_context(request)
catalog_pages = self.get_children().live().order_by('-order')
context['catalog_pages'] = catalog_pages
return context
content_panels = Page.content_panels + [
FieldPanel('intro', classname='full')
]
class Meta:
verbose_name = 'Главная страница каталога'
class CatalogPage(Page):
# todo добавить поле превью картинки
order = models.IntegerField(verbose_name='Порядок')
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
price = models.IntegerField(verbose_name='Цена')
search_fields = Page.search_fields + [
index.SearchField('intro'),
index.SearchField('body'),
]
content_panels = Page.content_panels + [
FieldPanel('intro'),
FieldPanel('body', classname='full'),
FieldPanel('price'),
FieldPanel('order'),
]
class Meta:
verbose_name = 'Проект'
сама ошибка возникает после добавления функции:
def get_context(self, request, *args, **kwargs):
context = super().get_context(request)
catalog_pages = self.get_children().live().order_by('-order')
context['catalog_pages'] = catalog_pages
return context