Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error adding translation for Injected Fields #1843

Open
bookhankaa opened this issue Feb 20, 2018 · 6 comments
Open

Error adding translation for Injected Fields #1843

bookhankaa opened this issue Feb 20, 2018 · 6 comments

Comments

@bookhankaa
Copy link

Following for this section of manual Translation for Injected Fields I'm trying to add translated extrafield for RichTextPage model:
settings.py

EXTRA_MODEL_FIELDS = (
    (
        "mezzanine.pages.models.RichTextPage.quote",
        "TextField",
        ("Page's Quote",),
        {"blank": True},
    ),
)

translation.py

from modeltranslation.translator import translator
from mezzanine.pages.translation import TranslatedRichTextPage
from mezzanine.pages.models import RichTextPage

class TranslatedInjectedPage(TranslatedRichTextPage):
    fields = ('quote',),

translator.unregister(RichTextPage)
translator.register(RichTextPage, TranslatedInjectedPage)

and I get:

Error adding translation field. Model 'RichTextPage' already contains a field named 'content_en'.
@bookhankaa
Copy link
Author

from modeltranslation.translator import translator, TranslationOptions
from mezzanine.pages.models import RichTextPage

class TranslatedInjectedPage(TranslationOptions):
    fields = ('quote',),

translator.unregister(RichTextPage)
translator.register(RichTextPage, TranslatedInjectedPage)

All fields and quote field transleted, content field NOT transleted.

@bookhankaa
Copy link
Author

And just simple:

from modeltranslation.translator import translator
from mezzanine.pages.translation import TranslatedRichTextPage
from mezzanine.pages.models import RichTextPage

translator.unregister(RichTextPage)
translator.register(RichTextPage, TranslatedRichTextPage)

Doesn't works with error:
Model 'RichTextPage' already contains a field named 'content_en'.

@antnieszka
Copy link

I have a similar problem - running version from master, commit aea2e99

@abusquets
Copy link

Me too

@mfoacs
Copy link

mfoacs commented Jul 16, 2018

same here, 4.3.0 stable.

@Kniyl
Copy link
Collaborator

Kniyl commented Jul 17, 2018

This is a bug of django-modeltranslation that never got addressed.

One workaround would be to manually add translated fields using EXTRA_MODEL_FIELDS for each target language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants