I have some existing project, But when I tried to use modeltranslation it generated an empty field for the model. After that, I tried modeltranslation command to fill out an empty field but it simply populated the empty field with original data, not with a translated version of original data.
@last-partizan is something that I am missing out.
I don't know why the translated version of the original data doesn't add up to the newly generated fields.
@last-partizan How can I get out from this problem.
@last-partizan , How can I use the field that I was using before the modeltranslation.
In setting.py, I have defined the following thing,
LANGUAGES = (
So after this my templates are showing 'hi' fields,
for example, they are showing the content of 'title_hi', but I want to show 'title' content, not 'title_hi', how can I do this?
I don't want the '_hi' should overtake my original content.
Hi @last-partizan ,
I have some queries related to the django-rest-framework method integration with django-modeltranslation.
def get_queryset(self): user_language = self.request.GET.get('language') return Model.objects.get_language(user_language).all()
For example, can I get particular language data similar to this '?language=en'?
django-modeltranslation uses current language from django, i suppose it's better to use something like LocaleMiddleware
or if you want direct approach, something like this:
def list(self, request, ...): lang = ... with translation.activate(lang): return super().list(request, ...)