Q
Q
Quixt2019-06-25 22:54:51
Django
Quixt, 2019-06-25 22:54:51

How to make wagtail-modeltranslation friends?

Please help with wagtail-modeltranslation
Swear words:
File "/home/vladimir/projects/python/django/ESF3/virtualenv/lib/python3.7/site-packages/django/forms/models.py", line 266, in new
raise FieldError(message)
django.core.exceptions.FieldError: Unknown field(s) (seo_title_fr, slug_fr, search_description_fr) specified for BlogIndexPage

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


# Keep the definition of BlogIndexPage, and add:

class BlogIndexPage(Page):
    intro = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('intro', classname="full")
    ]
class BlogPage(Page):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    body = RichTextField(blank=True)


    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    content_panels = Page.content_panels + [
        FieldPanel('date'),
        FieldPanel('intro'),
        FieldPanel('body', classname="full"),
    ]


from .models import BlogPage
from modeltranslation.translator import TranslationOptions
from modeltranslation.decorators import register

@register(BlogPage)
class BlogPageTR(TranslationOptions):
    fields = (
        'body',
    )

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question