modeltranslation and proxy models

143 views
Skip to first unread message

Andre Nitschke

unread,
May 6, 2015, 10:05:01 AM5/6/15
to django-mode...@googlegroups.com
Hy,

in first sorry for my bad english,

i use the new 0.9 version of django-modeltranslation with the latest checkout from django v1.8. Since i had upgraded have problems with my categories app based on django-mptt. 

I have an base category class for mptt-handling and 2 proxy models based on it for trees and the categories

for example:

models.py


class BaseCategory(MPTTModel):
    name = models.CharField(_('name'), max_length=255)
    ...

class CategoryTree(BaseCategory):
    class Meta:
        proxy = True

class Category(BaseCategory):
    class Meta:
        proxy = True



translation.py


class BaseTransOpts(TranslationOptions):
    fields = ('name',)

translator.register(BaseCategory, BaseTransOpts)
translator.register(CategoryTree, BaseTransOpts)
translator.register(Category, BaseTransOpts)



The Problem is in DjangoAdminClasses for the proxy models the fields which should translated are not available. When i set it explizit in fields property of TranslationAdmin i get an FieldError:
Unknown field(s) (name_de) specified for CategoryTree. Check fields/fieldsets/exclude attributes of class CategoryTreeAdmin

Also when i set name in list_display property i get a NoneType Error

I have check the problem over the python-shell. When i ask the Meta-Api with get_fields() the TranslationFields are listed but when i try to get the field with get_field('name_de') - i get an FieldDoesNotExist Exception.
Also when try with print the value - i get an 'object has no attribute 'name_de' Exception.

I have create an TranslationAdminClass for the BaseCategory-Model for testing, there are no problems.

What can i do?

Zaher Sarieddine

unread,
Jun 6, 2015, 11:20:16 AM6/6/15
to django-mode...@googlegroups.com
I have a similar problem and spent a whole day trying to find some hint but with no luck, I thought of asking you if you did find a solution

thank you
zaher
Message has been deleted

Ahmed Saad

unread,
Jul 29, 2015, 5:38:30 AM7/29/15
to django-modeltranslation, in...@zendux.de
same here, I've the same problem.

Piotr Ratajczak

unread,
Aug 26, 2015, 4:19:48 AM8/26/15
to django-modeltranslation
same here.
Reply all
Reply to author
Forward
0 new messages