EDIT: my bad, i had:
translations = TranslatedFields(
title=models.CharField(_('Title'), unique=False, max_length=40, null=False, blank=False)
)
I had unique=True
, that was the reason, so now the question is how do I require unique title for each language (for example, so there is only one 'Sport' for english language but not in general including all the translations), can I add constraint directly in models.py
?
---------------------------------------------------
I've just added django-parlel to my project and I'm wondering is it my bad or it's really impossible to have same translation more then once.
Case I'm trying to add translation for Polish language for word "Sport", in polish it would be "Sport", just same as in English (which I have by default in app). When trying to add this getting error both when adding from admin panel and when loading fixture. I know that i might leave it blank and it won't really be that bad however I need to have translation for each single word. I'm assuming there is a constraint in parlel
Polish:
Please correct the error below.
Interests Group Translation with this Title already exists.
Interests Group Translation with this Title already exists.
Title: [Sport]
django-parlel settings:
PARLER_LANGUAGES = {
None: (
{'code': 'en',}, # English
{'code': 'pl',}, # Polish
{'code': 'uk',}, # Ukrainian
),
'default': {
'fallbacks': ['en'],
'hide_untranslated': False,
}
}
Model:
class InterestsGroup(TranslatableModel):
'''
Group for storing similar interests (that are related to same topic)
'''
translations = TranslatedFields(
title=models.CharField(_('Title'), unique=True, max_length=40, null=False, blank=False)
)
class Meta:
verbose_name = _('Interests Group')
verbose_name_plural = _('Interests Groups')
ordering = ['id']
Adding this solved my problem: