Code Monkey home page Code Monkey logo

Comments (5)

vdboor avatar vdboor commented on May 29, 2024

The Django management commands activate "en-us" by default. The settings are completely left alone. Django 1.8 also changes this behavior.

I dont think there is much we can do here, expect for adding a nice warning in the docs. I'd be really grateful if you can provide a nice PR for this.

from django-parler.

vstoykov avatar vstoykov commented on May 29, 2024

@mrmachine when objects are created they depend on django.utils.translation.get_language() which is the current active language used from django i18n system.

Code executed not in the request/response cycle is not guaranteed to behave as you think if you do not use translation.activate or translation.overwrite.

As @vdboor said in Django 1.8 translation system is not activated in management commands and translation.get_language() will return None, which will make it impossible to save the object if you are not activated transaltion system with translation.activate(settings.LANGUAGE_CODE) or something you prefer.

I think that there is nothing that can be done from django-parler for now and issue need to be closed.

from django-parler.

vdboor avatar vdboor commented on May 29, 2024

Correct! Fact of dev-life is, that all projects had to adapt to using translation.activate() if they needed it.

from django-parler.

mrmachine avatar mrmachine commented on May 29, 2024

@vdboor is it true now that with Django 1.8 we must call activate(settings.LANGUAGE_CODE) in every interactive shell or management command that queries a model with translatable fields?

from django-parler.

vdboor avatar vdboor commented on May 29, 2024

Sadly yes. Django changes this https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/#management-commands-and-locales While I'm not happy about the change, the rationale in https://code.djangoproject.com/ticket/24073 gives some hints why this was done.

You can also use Model.objects.language(settings.LANGUAGE_CODE) to query them.

from django-parler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.