Merge pull request #235 from Pomax/patch-1

Fixes #234
This commit is contained in:
Diogo Marques 2019-03-21 12:04:09 +00:00 committed by GitHub
commit 7d9b42f542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,9 +10,22 @@ class ModeltranslationConfig(AppConfig):
def ready(self):
from django.conf import settings
from modeltranslation import settings as mt_settings
# Add Wagtail defined fields as modeltranslation custom fields
setattr(settings, 'MODELTRANSLATION_CUSTOM_FIELDS', getattr(settings, 'MODELTRANSLATION_CUSTOM_FIELDS', ()) + (
'StreamField', 'RichTextField'))
wagtail_fields = (
'StreamField',
'RichTextField',
)
# update both the standard settings and the modeltranslation settings,
# as we cannot guarantee the load order, and so django_modeltranslation
# may bootstrap itself either before, or after, our ready() gets called.
custom_fields = getattr(settings, 'MODELTRANSLATION_CUSTOM_FIELDS', tuple())
setattr(settings, 'MODELTRANSLATION_CUSTOM_FIELDS', tuple(set(custom_fields + wagtail_fields)))
mt_custom_fields = getattr(mt_settings, 'CUSTOM_FIELDS', tuple())
setattr(mt_settings, 'CUSTOM_FIELDS', tuple(set(mt_custom_fields + wagtail_fields)))
from modeltranslation.models import handle_translation_registrations
handle_translation_registrations()