Opened 14 years ago

Closed 14 years ago

#15073 closed (invalid)

django i18n issue

Reported by: rameshsahoo Owned by: nobody
Component: *.djangoproject.com Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am trying to generate an .mo file from a .po file using django-admin.py compilemessages. I am having Django 1.2.3 on Centos 5.4 with mod_wsgi. The issue is when I try to run the command which is os.system("django-admin.py compilemessages") from my project directory which is "/var/opt/project-name", it throws an error.

Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/django/bin/django-admin.py", line 5, in ?

management.execute_from_command_line()

File "/usr/lib/python2.4/site-packages/django/core/management/init.py", line 429, in execute_from_command_line

utility.execute()

File "/usr/lib/python2.4/site-packages/django/core/management/init.py", line 379, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "/usr/lib/python2.4/site-packages/django/core/management/base.py", line 191, in run_from_argv

self.execute(*args, options.dict)

File "/usr/lib/python2.4/site-packages/django/core/management/base.py", line 220, in execute

output = self.handle(*args, options)

File "/usr/lib/python2.4/site-packages/django/core/management/commands/compilemessages.py", line 52, in handle

compile_messages(locale)

File "/usr/lib/python2.4/site-packages/django/core/management/commands/compilemessages.py", line 10, in compile_messages

basedirs.extend(settings.LOCALE_PATHS)

File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 276, in getattr

self._setup()

File "/usr/lib/python2.4/site-packages/django/conf/init.py", line 40, in _setup

self._wrapped = Settings(settings_module)

File "/usr/lib/python2.4/site-packages/django/conf/init.py", line 74, in init

raise ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'project.settings' (Is it on sys.path? Does it have syntax errors?): No module named project.settings
256

The exact steps that I followed is as follows:
(This is from the project directory)
$ python manage.py shell

import os
os.system("django-admin.py compilemessages")

The minute I do enter, it throws this error. I have appended my project path in sys.path still its not working.
My mod_wsgi configuration is:

import os, sys
sys.path.append('/var/opt')
#sys.path.insert(0, '/var/opt')
sys.path.insert(0, '/var/opt/project')
os.environDJANGO_SETTINGS_MODULE = 'project.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Change History (1)

comment:1 by Adam Gomaa, 14 years ago

Resolution: invalid
Status: newclosed

Setting DJANGO_SETTINGS_MODULE in your mod_wsgi .wsgi file doesn't set it on the command line. There's also no reason to be using os.system(). Also, modifying sys.path in your .wsgi file (or in a django-admin.py shell) won't pass through to os.system().

You want something like:

$ cd /path/to/above/project
$ DJANGO_SETTINGS_MODULE=project.settings django-admin.py compilemessages

If this doesn't do it for you, please ask on django-users:

http://groups.google.com/group/django-users

Or check out the FAQ page for getting help:

http://docs.djangoproject.com/en/dev/faq/help/

This bugtracker is for bugs or features in Django, not for support.

Note: See TracTickets for help on using tickets.
Back to Top