Open romansemko opened 8 years ago
Django v1.8.6 - same behaviour.
I'm having the same issue with normal inheritance, also after upgrading.
Fixed by loading modeltranslation
before django.contrib.admin
in INSTALLED_APPS
.
Interesting, it will be very useful put that in the documentation.
Gosh, it's there, just read it carefully: http://django-modeltranslation.readthedocs.org/en/latest/installation.html#required-settings
@romansemko
You need to change SegmentOptions
to NOT inherit from BaseSegmentOptions
.
That's because fields are inherited this way: http://django-modeltranslation.readthedocs.org/en/latest/registration.html#translationoptions-fields-inheritance
And SegmentOptions.fields == ('name', 'label', 'description')
. But name
is the field not on Segment
, but on BaseSegment
only.
Just inherit SegmentOptions
from TranslationOptions
.
No other change in your code is required.
.
It is all a bit un-intuitive at first but you'll figure it out when you go through the codebase.
This scenario could have been handled more elegantly though.
I am having problems with simple inheritance.
Here is my models.py:
And my translation.py:
This does not work, Django (1.8.0) complains when trying to makemigrations:
I have tried just registering the SegmentModel, practically without this line
But then, modeltranslation complains:
I have tried skipping BaseSegment alltogether, adding the 'name' field to SegmentOptions, but then the 'name' field seems completely empty (although it is already pre-populated in the 'name' field in BaseSegment).
What am I doing wrong?