AttributeError: 'Environment' object has no attribute 'install_gettext_translations' #105

Closed
gandriyko opened this Issue Mar 22, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@gandriyko

Hi.
I use Django 1.7.7 with Jinja2 2.7.3 via django-jinja 1.1.1.
After update to django-jinja 1.3.1 got error:

./manage.py runserver
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
    app_config.ready()
  File "/usr/lib/python2.7/site-packages/django_jinja/apps.py", line 15, in ready
    base.setup()
  File "/usr/lib/python2.7/site-packages/django_jinja/base.py", line 300, in setup
    initialize(env)
  File "/usr/lib/python2.7/site-packages/django_jinja/base.py", line 282, in initialize
    _initialize_i18n(environment)
  File "/usr/lib/python2.7/site-packages/django_jinja/base.py", line 207, in _initialize_i18n
    env.install_gettext_translations(translation, newstyle=JINJA2_NEWSTYLE_GETTEXT)
AttributeError: 'Environment' object has no attribute 'install_gettext_translations'
@niwinz

This comment has been minimized.

Show comment
Hide comment
@niwinz

niwinz Mar 22, 2015

Owner

Hi @gandriyko

Can you give me more information. You are using something special? You are overwriting the jinja environment?

I asking this because the jinja2 standard environment object/class has the method install_gettext_translations: http://jinja.pocoo.org/docs/dev/extensions/#jinja2.Environment.install_gettext_translations

And django_jinja run on travis with different python versions and different django versions and all tests passes :S

Owner

niwinz commented Mar 22, 2015

Hi @gandriyko

Can you give me more information. You are using something special? You are overwriting the jinja environment?

I asking this because the jinja2 standard environment object/class has the method install_gettext_translations: http://jinja.pocoo.org/docs/dev/extensions/#jinja2.Environment.install_gettext_translations

And django_jinja run on travis with different python versions and different django versions and all tests passes :S

@gandriyko

This comment has been minimized.

Show comment
Hide comment
@gandriyko

gandriyko Mar 22, 2015

In django-jinja 1.1.1 all works, but not in new version.

in settings.py I have

JINJA2_EXTENSIONS = ['gutils.utils.templates.CacheExtension']
# JINJA2_EXTENSIONS = []

when commenting this string all working normaly.

In django-jinja 1.1.1 all works, but not in new version.

in settings.py I have

JINJA2_EXTENSIONS = ['gutils.utils.templates.CacheExtension']
# JINJA2_EXTENSIONS = []

when commenting this string all working normaly.

@gandriyko

This comment has been minimized.

Show comment
Hide comment
@gandriyko

gandriyko Mar 22, 2015

I found that CacheExtension already in default Extensions

DEFAULT_EXTENSIONS = [
    "jinja2.ext.do",
    "jinja2.ext.loopcontrols",
    "jinja2.ext.with_",
    "jinja2.ext.i18n",
    "jinja2.ext.autoescape",
    "django_jinja.builtins.extensions.CsrfExtension",
    "django_jinja.builtins.extensions.CacheExtension",
    "django_jinja.builtins.extensions.TimezoneExtension",
    "django_jinja.builtins.extensions.UrlsExtension",
    "django_jinja.builtins.extensions.StaticFilesExtension",
    "django_jinja.builtins.extensions.DjangoFiltersExtension",
]

I found that CacheExtension already in default Extensions

DEFAULT_EXTENSIONS = [
    "jinja2.ext.do",
    "jinja2.ext.loopcontrols",
    "jinja2.ext.with_",
    "jinja2.ext.i18n",
    "jinja2.ext.autoescape",
    "django_jinja.builtins.extensions.CsrfExtension",
    "django_jinja.builtins.extensions.CacheExtension",
    "django_jinja.builtins.extensions.TimezoneExtension",
    "django_jinja.builtins.extensions.UrlsExtension",
    "django_jinja.builtins.extensions.StaticFilesExtension",
    "django_jinja.builtins.extensions.DjangoFiltersExtension",
]
@gandriyko

This comment has been minimized.

Show comment
Hide comment
@gandriyko

gandriyko Mar 22, 2015

Thanks, I realized.

Thanks, I realized.

@niwinz

This comment has been minimized.

Show comment
Hide comment
@niwinz

niwinz Mar 22, 2015

Owner

Take care that if you set JINJA2_EXTENSIONS = ['gutils.utils.templates.CacheExtension'] in your settings, you are overwriting the default values.

Owner

niwinz commented Mar 22, 2015

Take care that if you set JINJA2_EXTENSIONS = ['gutils.utils.templates.CacheExtension'] in your settings, you are overwriting the default values.

@niwinz niwinz closed this Mar 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment