django-modeltranslation
django-modeltranslation copied to clipboard
django.db.utils.ProgrammingError in update_translation_fields
Hi!
I have the file (translation.py):
from modeltranslation.translator import translator, TranslationOptions
from django.contrib.flatpages.models import FlatPage
from staticpages.models import ExtendedFlatPage # inherited from FlatPage
class FlatPageTranslationOptions(TranslationOptions):
pass
class ExtendedFlatPageTranslationOptions(FlatPageTranslationOptions):
fields = ('title', 'content')
translator.register(FlatPage, FlatPageTranslationOptions)
translator.register(ExtendedFlatPage, ExtendedFlatPageTranslationOptions)
And I got the following error:
File "d:\projects\mesto.ua\mesto\.buildout\eggs\django-1.7.6-py2.7.egg\django\db\backends\utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: missing FROM-clause entry for table "django_flatpage"
LINE 1: ..."staticpages_extendedflatpage" SET "content_ru" = "django_fl...
^
django-1.7.6, django-modeltranslation-0.9
In Mezzanine, I use fields = ()
instead of pass
whenever there is no (or no more) fields to translate. Can you make the change to see if it helps solving your issue?
Thanks! I have tried fields = ()
, and I got the same exception. ExtendedFlatPage
(is inherited from FlatPage
) haven't title
and content
fields, but I attach translation fields (title_*
and content_*
) to ExtendedFlatPage
instead of FlatPage
. It seems to me, the command is not so flexible to handle this situation.
Just got hit by this same issue. @aalebedev, did you find a solution for this? Thanks
@dmarcelino
Now I have my own models of flat pages, and the problem was gone :)
When I used django-modeltranslations on Django's FlatPage, I wrote my own version of "update_translation_fields" command. It was copy of original command with extra lines, something like if model in (ExtendedFlatPage, FlatPage): continue
. "Dirty" solution :)
Gotcha! Thanks @aalebedev
Hi,
I have the same problem when translating django-filer:
from filer.models.imagemodels import Image
from modeltranslation.translator import TranslationOptions, register
@register(File)
class FileTranslationOptions(TranslationOptions):
fields = ()
@register(Image)
class ImageTranslationOptions(TranslationOptions):
fields = ('description')
Used same solution as @aalebedev