Сбой makejigrations в django при попытке добавить ForeignKey к существующей модели

У меня есть модель, и я пытаюсь добавить к ней поле с иностранными ключами.

Это определение поля:

part_of_speech = models.ForeignKey('PartOfSpeech', help_text=_('Translation | part_of_speech | help_text'), verbose_name = _('Translation','part_of_speech'))

Когда я пытаюсь выполнить makemigrations Команда, я получаю следующую ошибку:

Migrations for 'dictionary':
  0024_translation_part_of_speech.py:
    - Add field part_of_speech to translation
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 143, in handle
    self.write_migration_files(changes)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 171, in write_migration_files
    migration_string = writer.as_string()
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/db/migrations/writer.py", line 146, in as_string
    operation_string, operation_imports = OperationWriter(operation).serialize()
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/db/migrations/writer.py", line 104, in serialize
    _write(arg_name, arg_value)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/db/migrations/writer.py", line 74, in _write
    arg_string, arg_imports = MigrationWriter.serialize(_arg_value)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/db/migrations/writer.py", line 354, in serialize
    return cls.serialize_deconstructed(path, args, kwargs)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/db/migrations/writer.py", line 248, in serialize_deconstructed
    arg_string, arg_imports = cls.serialize(arg)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/db/migrations/writer.py", line 276, in serialize
    value = force_text(value)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/utils/encoding.py", line 92, in force_text
    s = six.text_type(s)
  File "/Users/user/.virtualenvs/env2/lib/python2.7/site-packages/django/utils/functional.py", line 141, in __text_cast
    return func(*self.__args, **self.__kw)
TypeError: ugettext() takes exactly 1 argument (2 given)

1 ответ

Решение

Объявление текста справки (вызов ugetttext) отформатировано неправильно. Чтобы решить эту проблему, измените это:

verbose_name = _('Translation','part_of_speech')

к этому:

verbose_name = _('Translation | part_of_speech')
Другие вопросы по тегам