我正在从 Django == 1.7.8 升级到 Django == 1.8.2 ,我遇到了这个问题,导致我无法创建新的迁移到抑制它。
我有一个看起来像这样的设置
从单独的包中我有以下
class Category(MyModel, Mixin):
name = models.CharField(max_length=255)
slug = models.SlugField(unique=True)
在我的django应用程序中,我有以下
from mypackage.myapp.models import Category
class Section(Category):
class Meta(Category.Meta):
proxy = True
当我升级到Django==1.8.2
时,收到以下错误
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/test/runner.py", line 210, in run_tests
old_config = self.setup_databases()
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/test/runner.py", line 166, in setup_databases
**kwargs
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/test/runner.py", line 370, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 368, in create_test_db
test_flush=not keepdb,
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 221, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 104, in migrate
state = migration.mutate_state(state, preserve=do_run)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 83, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 53, in state_forwards
list(self.managers),
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 81, in add_model
self.reload_model(app_label, model_name)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 152, in reload_model
self.apps.render_multiple(states_to_be_rendered)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 262, in render_multiple
model.render(self)
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 546, in render
body,
File "/var/venvs/myproject/local/lib/python2.7/site-packages/django/db/models/base.py", line 216, in __new__
raise TypeError("Proxy model '%s' has no non-abstract model base class." % name)
TypeError: Proxy model 'Section' has no non-abstract model base class.
我有点困惑,因为当我访问代理模型的parents属性时,它具有相应的Category
模型,而Category._meta.abstract
返回False
。我进入了发生错误的堆栈,当它将我的Section
模型作为基类Category
的代理进行评估时,它会通过,但它会继续使用ModelBase
进行测试它失败了