问题描述
我正在尝试将i8n添加到Django应用程序中,但执行时:
(venv)user @ machine :〜/ path / to / repo $ django-admin makemessages -l es
下一个错误被抛出:
PermissionError:[Errno 13]权限被拒绝:'./venv/lib/python3.5/site-packages/Jinja2 -2.9.5.dist-info / LICENSE.txt.py'
但是如果我用它manage.py而不是django-admin它可以正常工作。在django文档中,他们建议使用django-admin。
任何想法?
Django的文档并不真正地推荐使用 django-admin
而不是 ./ manage.py
- 实际上是:
原因是:
实际上第二点并不完全准确 - ./ manage.py
只设置 DJANGO_SETTINGS_MODULE
如果它不是已经设置在你的环境中。
所以当使用 django-admin
确定它会找到您的设置模块(通过设置环境变量或通过使用 - 设置
选项),并且您的项目的根位于您的pythonpath中。
实际上,除了 startproject
命令 - 根据定义,您还没有一个 ./ manage.py
文件 - 没有理由使用 django-admin
,除非你想明确地使用不同的设置模块,而无需更改环境变量。
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?
Django's doc does not really "recommand" to use django-admin
instead of ./manage.py
- actually the doc states that:
The reason being that:
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.
这篇关于Django中的权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!