python - 升级到 Django 1.7。 AssertionError : To use StatusField, 模型 'ShellRequest' 必须具有 STATUS 选择类属性

标签 python django django-models django-rest-framework

我从 Django 1.6 升级到 1.7。安装了与 Django 1.7 兼容的 Python 2.7。当我运行代码 python manage.py makemigrations 时,我收到以下错误消息:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/m                           akemigrations.py", line 111, in handle
    convert_apps=app_labels or None,
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/autodetector.py", line 42, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/autodetector.py", line 109, in _detect_changes
    self.old_apps = self.from_state.render(ignore_swappable=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 67, in render
    model.render(self.apps)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 312, in render
    body,
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 284, in __new__
    new_class._prepare()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 344, in _prepare
    signals.class_prepared.send(sender=cls)
  File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 198, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/local/lib/python2.7/dist-packages/model_utils/fields.py", line 57, in prepare_class
    % sender.__name__
AssertionError: To use StatusField, the model 'ShellRequest' must have a STATUS choices class attribute.

阅读博文here ,我不知道从哪里开始。如果有人能给我指导如何处理这个问题,我将不胜感激。

最佳答案

choices 类字段属性可能就是您正在寻找的。

如果您使用django-model-utils choices 包文档的部分也可能有帮助。

关于python - 升级到 Django 1.7。 AssertionError : To use StatusField, 模型 'ShellRequest' 必须具有 STATUS 选择类属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43985015/

相关文章:

python - Django:为什么有些模型字段会相互冲突?

python - App Engine 正则表达式问题将 URL 定向到脚本和处理程序

python - pandas dataframe 可以在新窗口中呈现吗?

django - 使用 Nginx 和 CloudFlare 时如何将真实 IP 传递给 Gunicorn?

python - 运行Django时Python意外退出

python-3.x - 系统找不到指定的路径: error returned when changing field in admin page Django

python - 判断闰年

python - 为什么我不能在 Raspberry Pi 上使用 python-mosquitto?

ios - native ios 应用程序的 Django 模板

python - 将数据保存到数据库时出错