I18n has stopped working

I always use this script to compile django.po, and it always worked:

#!/bin/sh django-admin.py makemessages -a django-admin.py compilemessages 

Suddenly, it stops working with this error:

 $ i18n.sh Traceback (most recent call last): File "c:/Python34/Scripts/django-admin.py", line 5, in <module> management.execute_from_command_line() File "c:\Python34\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line utility.execute() File "c:\Python34\lib\site-packages\django\core\management\__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "c:\Python34\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File "c:\Python34\lib\site-packages\django\core\management\base.py", line 338, in execute output = self.handle(*args, **options) File "c:\Python34\lib\site-packages\django\core\management\base.py", line 533, in handle return self.handle_noargs(**options) File "c:\Python34\lib\site-packages\django\core\management\commands\makemessag es.py", line 283, in handle_noargs potfiles = self.build_potfiles() File "c:\Python34\lib\site-packages\django\core\management\commands\makemessag es.py", line 299, in build_potfiles file_list = self.find_files(".") File "c:\Python34\lib\site-packages\django\core\management\commands\makemessag es.py", line 358, in find_files ignored_roots = [os.path.normpath(p) for p in (settings.MEDIA_ROOT, settings .STATIC_ROOT)] File "c:\Python34\lib\site-packages\django\core\management\commands\makemessag es.py", line 358, in <listcomp> ignored_roots = [os.path.normpath(p) for p in (settings.MEDIA_ROOT, settings .STATIC_ROOT)] File "c:\Python34\lib\ntpath.py", line 491, in normpath if path.startswith(special_prefixes): AttributeError: 'NoneType' object has no attribute 'startswith' processing file django.po in c:\Users\Debora\workspace\opti\opti2.0\project\loca le\pt_BR\LC_MESSAGES 

Does anyone have any ideas?

I do not know what caused this. I recently upgraded django 1.7 to 1.7.1, installed some unrelated packages, that what I remember could have an effect.

+6
source share
6 answers

Just set STATIC_ROOT in the settings.py file.

This is a bug in Django 1.7.1 and should be removed in Django 1.7.2

(Since Django 1.6.2 STATIC_ROOT is None by default, before '' .)

+2
source

Was there the same problem after upgrading to Django 1.7

I fixed it by specifying a settings module every time I run django-admin.py :

 cd ~/myproject/myproject # where the ``locale`` folder exists PYTHONPATH=~/myproject django-admin.py makemessages --settings=myproject.settings -l <language> 

Update: Bug fixed in Django 1.7.2: https://docs.djangoproject.com/en/1.7/releases/1.7.2/ https://code.djangoproject.com/ticket/23717

+5
source

First determine your local path for makemessages

 LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale/'), ) 

In terminal

$ python manage.py makemessages -l pl

go to the folder and open the file, edit the .po file

Then in the terminal

$ python manage.py compilemessages

It works fine in Django 1.7 and is updated too.

I think this may help you.

+3
source

The problem is that you did not set the STATIC_ROOT and MEDIA_ROOT . After that, do the following:

 MEDIA_ROOT = os.path.join(BASE_DIR, 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'static') 

I am using make_messages.sh script:

 #!/usr/bin/env bash for dir in `find -maxdepth 1 -type d ! -iname ".*"`; do echo $dir tmp=$(basename $dir) dir="$tmp" skip_this=0 for tmp in static media; do if [ "$dir" = "$tmp" ]; then skip_this=1 break fi done if [ "$skip_this" = "1" ]; then echo Skipping $dir continue fi cd `dirname $0`/$dir if [ ! -d locale ] ; then echo Creating 'locale' directory mkdir locale fi ../manage.py makemessages -l pl -l en -l de cd .. done 

and after doing make_messages.sh :

 ./static_page processing locale pl processing locale en processing locale de ./common Creating locale directory processing locale pl processing locale en processing locale de 

And this is my compile_messages.sh script:

 #!/usr/bin/env bash for dir in `find -maxdepth 1 -type d ! -iname ".*"`; do echo $dir tmp=$(basename $dir) dir="$tmp" skip_this=0 for tmp in static static_custom media; do if [ "$dir" = "$tmp" ]; then skip_this=1 break fi done if [ "$skip_this" = "1" ]; then echo Skipping $dir continue fi cd `dirname $0`/$dir ../manage.py compilemessages -l pl -l en -l de cd .. done 
+2
source

I had the same problems using Django 1.7.1.

I fixed it by changing the command: django-admin.py to python manage.py .

So my whole team is as follows:

python manage.py makemessages --locale=en --ignore=templates/admin --ignore=project/settings.py

+2
source

I had the same thing. I tried to run django-admin and got this problem.

When I run it with manage.py, it works fine.

 python manage_local.py makemessages -l cs --settings=gprojects.settings_local 

Use manage.py, manage_local.py is my alternate version.

0
source

Source: https://habr.com/ru/post/977538/


All Articles