Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2309 closed defect (fixed)

After introducing USE_I18N runserver throws exception

Reported by: Djordjevic Nebojsa <nesh at studioquattro co yu> Owned by: hugo
Component: Internationalization Version: master
Severity: major Keywords:
Cc: nesh@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When I start my dev server I got following exception:

$ PYTHONPATH=/Users/nesh/devel/workspace/riznica-mr/riznica:/store/django:/store/contrib/:/usr/local/lib/python2.4/site-packages/:/usr/bin/env python2.4 /Users/nesh/devel/workspace/riznica-mr/riznica/manage.py --settings=riznica.settings runserver
    
Traceback (most recent call last):
  File "/Users/nesh/devel/workspace/riznica-mr/riznica/manage.py", line 4, in ?
    import settings # Assumed to be in the same directory.
  File "/Users/nesh/devel/workspace/riznica-mr/riznica/settings.py", line 6, in ?
    from django.utils.translation import gettext_lazy as _
  File "/store/django/django/utils/translation/__init__.py", line 3, in ?
    if settings.USE_I18N:
  File "/store/django/django/conf/__init__.py", line 28, in __getattr__
    self._import_settings()
  File "/store/django/django/conf/__init__.py", line 53, in _import_settings
    raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.

or with

$ PYTHONPATH=/Users/nesh/devel/workspace/riznica-mr/riznica:/store/django:/store/contrib/:/usr/local/lib/python2.4/site-packages/ DJANGO_SETTINGS_MODULE=riznica.settings /usr/bin/env python2.4 /Users/nesh/devel/workspace/riznica-mr/riznica/manage.py --settings=riznica.settings runserver
      
Traceback (most recent call last):
  File "/Users/nesh/devel/workspace/riznica-mr/riznica/manage.py", line 4, in ?
    import settings # Assumed to be in the same directory.
  File "/Users/nesh/devel/workspace/riznica-mr/riznica/settings.py", line 6, in ?
    from django.utils.translation import gettext_lazy as _
  File "/store/django/django/utils/translation/__init__.py", line 3, in ?
    if settings.USE_I18N:
  File "/store/django/django/conf/__init__.py", line 28, in __getattr__
    self._import_settings()
  File "/store/django/django/conf/__init__.py", line 55, in _import_settings
    self._target = Settings(settings_module)
  File "/store/django/django/conf/__init__.py", line 83, in __init__
    raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: Could not import settings 'riznica.settings' (Is it on sys.path? Does it have syntax errors?): cannot import name gettext_lazy

Relevant part of setup.py:

from django.utils.translation import gettext_lazy as _
USE_I18N = True

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'sr'
LANGUAGES = (
    ('sr', _('Serbian')), 
    ('en', _('English')), 
    ('de', _('German')), 
    ('el', _('Greek')), 
    ('it', _('Italian')), 
)

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

The solution is *not* to import django.utils.translation in your settings file, because that module now depends on the settings being loaded. In [3318] I added some explanations to the docs -- check it out.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.