Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django,Django模型翻译_Django_Django Modeltranslation - Fatal编程技术网

Django,Django模型翻译

Django,Django模型翻译,django,django-modeltranslation,Django,Django Modeltranslation,我是模型翻译新手,有个问题。创建模型并在translation.py中注册要转换的字段后执行manage.py makemigrations myapp命令时,modeltranslation应用程序不会将转换后的字段添加到模型中。但字段在表中 modeltranslation:为转换注册了0个模型()[pid:8333] 在我的环境中.py from django.utils.translation import ugettext_lazy as _ gettext = lambda s: s

我是模型翻译新手,有个问题。创建模型并在translation.py中注册要转换的字段后执行manage.py makemigrations myapp命令时,modeltranslation应用程序不会将转换后的字段添加到模型中。但字段在表中

modeltranslation:为转换注册了0个模型()[pid:8333]

在我的环境中.py

from django.utils.translation import ugettext_lazy as _
gettext = lambda s: s
LANGUAGES = (
    ('hi', _('Hindi')),
    ('en', _('English')),

    ('ru', _('Russian')),
    ('ur', _('Urdu')),
    ('zh', _('Chinese')),
)



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

LANGUAGE_CODE = 'hi'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
from modeltranslation.translator import translator
STATIC_URL = '/static/'

MODELTRANSLATION_DEFAULT_LANGUAGE = 'hi'

MODELTRANSLATION_LANGUAGES = ('hi', 'en')

MODELTRANSLATION_FALLBACK_LANGUAGES = ('hi', 'en')

MODELTRANSLATION_PREPOPULATE_LANGUAGE = 'hi'


MODELTRANSLATION_TRANSLATION_FILES = (
    'i18ntest.translation',
)
在my models.py中

from django.db import models
from django.utils.translation import ugettext_lazy
from django.conf import settings

    class MyThing(models.Model):
        name = models.CharField(help_text=ugettext_lazy('This is the help text'),max_length = 150,null = True, blank = True)
        def __unicode__(self):
        return self.name

# Create your models here.


    class Profile(models.Model):
        name = models.CharField(max_length = 150,null = True, blank = True)

        def __unicode__(self):
            return self.name
在我的翻译中.py

from modeltranslation.translator import register,translator, TranslationOptions

from i18ntest.models import MyThing

@register(MyThing)

    class MyThingTranslationOptions(TranslationOptions):
        fields = ('name',

)

#translator.register(MyThing, MyThingTranslationOptions)
我正在使用django modeltranslation 0.12和django 1.10

服务器状态为

(envi18n) vinod@vinod-H81M-S:~/vinod/i18n/i18n$ ./manage.py runserver
modeltranslation: Registered 0 models for translation () [pid: 9065].
modeltranslation: Registered 0 models for translation () [pid: 9068].
Performing system checks...

System check identified no issues (0 silenced).
February 22, 2017 - 12:26:35
Django version 1.10, using settings 'i18n.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

翻译文件名中有一个输入错误。我必须是
translation.py
,单数