Code Monkey home page Code Monkey logo

Comments (8)

gandriyko avatar gandriyko commented on June 20, 2024

Yes, I wrote the same. All works fine if run as "manage.py runserver".
But if run project via uwsgi, raised following exception:

   File "/home/shop/shop/settings.py", line 295, in <module>
    jingo.env.install_gettext_translations(translation)
AttributeError: 'module' object has no attribute 'env'

But project running and works.

from jingo.

martinsvoboda avatar martinsvoboda commented on June 20, 2024

I work around this. I have gettext installation in the file of my private app jingoi18n/init.py
But for correct working it needs calling of admin.autodiscover() in urls.py of project. I think it's possible move instalation code to settings.py and it will works.

from jingo.

gandriyko avatar gandriyko commented on June 20, 2024

I try putting initialization code in settings.py already, same exception.

from jingo.

jsocol avatar jsocol commented on June 20, 2024

It looks like that exception has to do with jingo not being imported correctly before running jingo.env.install_gettext_translations(). The env object is created as an import-time side-effect of the jingo module. (Not a great way to do it, admittedly.)

runserver imports everything in INSTALLED_APPS when it runs model verification, so it works then. I'm guessing uwsgi doesn't have that init step. I've seen similar things with gunicorn and Raven, where I had to add a process start up hook to get the import-time side-effects.

How are you importing jingo in settings.py?

from jingo.

gandriyko avatar gandriyko commented on June 20, 2024

setttings.py:

import jingo.monkey
jingo.monkey.patch()

try:
    from django.utils import translation
    from jingo.import env
    env.install_gettext_translations(translation)
except:
    pass

from jingo.

jsocol avatar jsocol commented on June 20, 2024

env isn't a module, but monkey is. Try replacing the second import in the try: block with:

import jingo
jingo.env.install_gettext_translations(translation)

from jingo.

gandriyko avatar gandriyko commented on June 20, 2024

Just tried. Same errror:

jingo.env.install_gettext_translations(translation)
AttributeError: 'module' object has no attribute 'env'

from jingo.

jsocol avatar jsocol commented on June 20, 2024

Can anyone who ran into this try with Jingo 0.8? There are some changes (there's no jingo.env anymore, but jingo.get_env() will return the instance) but the upgrade shouldn't be too rough.

from jingo.

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.