django-modeltranslation icon indicating copy to clipboard operation
django-modeltranslation copied to clipboard

Translating Django auth models

Open sueli-rabaca opened this issue 10 years ago • 6 comments

I would like to know the best way to translate authorization models, like Group and Permission (standard way, meaning, not customized).

Modeltranslation works perfectly with my apps, but I don’t know how to do it for “third parties” (since this is a Django class - django.contrib.auth.models).

My environment is Python 3.4.3 and Django 1.8.4, and migration is running. django-modeltranlation==0.10.1

Thanks in advance.

sueli-rabaca avatar Oct 07 '15 16:10 sueli-rabaca

It should be as easy as this:

from django.contrib.auth.models import Group
from modeltranslation.translator import translator, TranslationOptions

@register(Group)
class GroupTranslationOptions(TranslationOptions):
    fields = ('name',)  # or whatever these fields are called

zlorf avatar Oct 07 '15 17:10 zlorf

It was performed as suggested, but I received the following error:

ValueError: Could not find manager NewMultilingualManager in modeltranslation.translator.
Please note that you need to inherit from managers you dynamically generated with 'from_queryset()'.

Process finished with exit code 1

I tried to follow the issue issue #330, but it didn't work either. Any ideas?

sueli-rabaca avatar Oct 07 '15 18:10 sueli-rabaca

Same issue here. I put the modeltranslation on the Permission model of contrib.auth.models. Cannot update to Django 1.8 or higher due to this issue :(

gabn88 avatar Dec 13 '15 13:12 gabn88

yes, I tried Django 1.8.3 and Django 1.9, both gave this error. Django 1.7.9 is fine.

gabn88 avatar Dec 13 '15 13:12 gabn88

Current RC should fix this.

zlorf avatar Jan 01 '16 12:01 zlorf

We have to migrate django.contrib.auth models in order to use that, hence run 'makemigrations' on test and production servers; is there no better way?

xelnod avatar Apr 17 '17 14:04 xelnod