2014-11-04 75 views
3

我創造了語言的文件與django-admin.py makemessages -adjango-admin.py makemessages失敗

一點點發展較晚的所有嘗試創建* .po文件與失敗:

django-admin.py makemessages -v 3 -a 
examining files with the extensions: .html and .txt 
Traceback (most recent call last): 
    File "/usr/local/bin/django-admin.py", line 5, in <module> 
    management.execute_from_command_line() 
    File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py",   line 385, in execute_from_command_line 
utility.execute() 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line  377, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 288, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 338, in execute 
output = self.handle(*args, **options) 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 533, in handle 
return self.handle_noargs(**options) 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/makemessages.py", line 283, in handle_noargs 
potfiles = self.build_potfiles() 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/makemessages.py", line 299, in build_potfiles 
file_list = self.find_files(".") 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/makemessages.py", line 358, in find_files 
ignored_roots = [os.path.normpath(p) for p in (settings.MEDIA_ROOT, settings.STATIC_ROOT)] 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/makemessages.py", line 358, in <listcomp> 
ignored_roots = [os.path.normpath(p) for p in (settings.MEDIA_ROOT, settings.STATIC_ROOT)] 
File "/usr/lib/python3.4/posixpath.py", line 335, in normpath 
initial_slashes = path.startswith(sep) 
AttributeError: 'NoneType' object has no attribute 'startswith' 

我試了一下幾個文件擴展名和-ignore模式。 你有什麼提示嗎?

+0

您是否檢查過以確保'''settings.MEDIA_ROOT'''''' settings.STATIC_ROOT'''存在且有效? – schillingt 2014-11-04 21:02:15

+0

我已triied設置它們是這樣的: 'STATIC_ROOT =( os.path.join(BASE_DIR, '靜態'), )' 或以 '/無功/網絡/ projectroot /靜態' – Lioman 2014-11-04 21:45:28

+0

好的是奇怪的是:我使用vagrant進行開發,所描述的錯誤發生在那裏,而其他任何命令都不會產生錯誤。我已經在主機上試了一下,一切正常。 – Lioman 2014-11-05 08:07:57

回答

1

這是由於在Django 1.7.1推出了bug。你可以通過更新你的Django到最新版本來解決這個問題:

pip install -U django 

P.S.相關的StackOverflow問題和解答可以在這裏找到herehere

1

自django 1.7以來,我有同樣的問題。我用manage.py做消息而不是django-admin.py排除環境文件夾:

python manage.py makemessages --locale=en --ignore=venv/*