#26940 closed Bug (fixed)
makemessages incorrectly configured as not requiring settings
Reported by: | Jorge Romero | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | translations |
Cc: | Claude Paroz | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django-admin and manage.py are supposed to be interchangeable.
From the docs(https://docs.djangoproject.com/en/1.9/ref/django-admin/):
The command-line examples throughout this document use django-admin to be consistent, but any example can use manage.py or python -m django just as well.
However, this doesn't seem to be true for makemessages.
If I run manage.py makemessages from the top level of the project MEDIA_ROOT and STATIC_ROOT are ignored. This isn't precisely a bug because that's what the code is intended to do (https://github.com/django/django/blob/master/django/core/management/commands/makemessages.py#L448), but I find it strange specially for --domain djangojs because is very common for Javascript files to be put in STATIC_ROOT.
django-admin makemessages doesn't ignore MEDIA_ROOT or STATIC_ROOT and it traverses the entire source tree.
At least this should be explained in the documentation. At best both commands should do the exact same. It's very easy to be bitten by this as we don't always review the resulting *.po file.
Am I missing something here?
Change History (12)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Bug |
Currently, makemessages
is explicitly whitelisted as not needing a configured settings file (see no_settings_commands
in django.core.management.__init__.py
.
I wonder now if we should revert that, considering the dependency of that command on settings.FILE_CHARSET
, settings.LOCALE_PATHS
, settings.MEDIA_ROOT
, and settings.STATIC_ROOT
.
comment:4 by , 9 years ago
Summary: | django-admin makemessages vs. manage.py makemessages → makemessages incorrectly configured as not requiring settings |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:6 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
Triage Stage: | Ready for checkin → Unreviewed |
I'm considering reverting the fact that we require configured settings for makemessages.
I'm thinking about the use case of reusable apps, when you typically don't have/need STATIC_ROOT/MEDIA_ROOT/LOCALE_PATHS, and most of the time FILE_CHARSET in utf-8 is fine.
See this commit, above that PR.
comment:8 by , 9 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:10 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:11 by , 4 months ago
Cc: | added |
---|
There seems to be a potential regression about this in current main
(6.0 development cycle). When running:
$ django-admin --version 6.0.dev20250506141140
$ django-admin makemessages --all -v 2 Traceback (most recent call last): File "/home/nessita/.venvs/djangodev-3.13/bin/django-admin", line 8, in <module> sys.exit(execute_from_command_line()) ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/home/nessita/fellowship/django/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() ~~~~~~~~~~~~~~~^^ File "/home/nessita/fellowship/django/django/core/management/__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ File "/home/nessita/fellowship/django/django/core/management/base.py", line 416, in run_from_argv self.execute(*args, **cmd_options) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/home/nessita/fellowship/django/django/core/management/base.py", line 460, in execute output = self.handle(*args, **options) File "/home/nessita/fellowship/django/django/core/management/commands/makemessages.py", line 372, in handle % get_text_list(list(self.extensions), "and") ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nessita/fellowship/django/django/utils/functional.py", line 231, in wrapper return func(*args, **kwargs) File "/home/nessita/fellowship/django/django/utils/text.py", line 306, in get_text_list _(", ").join(str(i) for i in list_[:-1]), ~^^^^^^ File "/home/nessita/fellowship/django/django/utils/translation/__init__.py", line 96, in gettext return _trans.gettext(message) ^^^^^^^^^^^^^^ File "/home/nessita/fellowship/django/django/utils/translation/__init__.py", line 66, in __getattr__ if settings.USE_I18N: ^^^^^^^^^^^^^^^^^ File "/home/nessita/fellowship/django/django/conf/__init__.py", line 75, in __getattr__ self._setup(name) ~~~~~~~~~~~^^^^^^ File "/home/nessita/fellowship/django/django/conf/__init__.py", line 55, in _setup raise ImproperlyConfigured( ...<4 lines>... ) django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
comment:12 by , 4 months ago
Thanks for noticing, we should probably deactivate translations around the call to get_text_list
.
Maybe the documentation should mention that
--settings
must be specified todjango-admin
andpython -m django
for them to be interchangeable withmanage.py
.