Permission denied in Django makemessages

断了今生、忘了曾经 提交于 2020-01-15 10:13:18

问题


I'm trying to add i8n into a Django app, but when I execute:

(venv) user@machine:~/path/to/repo$ django-admin makemessages -l es

The next error is thrown:

PermissionError: [Errno 13] Permission denied: './venv/lib/python3.5/site-packages/Jinja2-2.9.5.dist-info/LICENSE.txt.py'

But if I use it with manage.py instead of django-admin it works correctly. In django documentation they recommend to use django-admin.

Any ideas?


回答1:


Django's doc does not really "recommand" to use django-admin instead of ./manage.py - actually the doc states that:

Generally, when working on a single Django project, it’s easier to use manage.py than 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.

The reason being that:

In addition, manage.py is automatically created in each Django project. manage.py does the same thing as django-admin but takes care of a few things for you: It puts your project’s package on sys.path. It sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s settings.py file.

NB actually the second point is not totally exact - ./manage.py only sets DJANGO_SETTINGS_MODULE if it's not already set in your environnement.

So when using django-admin you have to make sure that it will find your settings module (either by settings the environnement variable or by passing it with the --settings option) and that your project's root is in your pythonpath.

Actually, except for the startproject command - where, by definition, you don't already have a ./manage.py file -, there's no reason to use django-admin at all unless you want to explicitly use a different settings module without changing your environnement variable.



来源:https://stackoverflow.com/questions/42718942/permission-denied-in-django-makemessages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!