无法创建测试数据库django
Can´t create test database django
我正在尝试测试 Django 应用程序,但是当我 运行 python manager.py 测试时我遇到了这个错误
django.db.utils.ProgrammingError: column deals_dealproposal.billing_branch_launcher_id does not exist
它发生在
File "/migrations/0008_dynamicpackingtype.py", line 18, in run
for proposal in bulk_proposals:
在这一点上,billing_branch_launcher 并不真正存在,它是在迁移 27
中创建的
migrations.AddField(
model_name='dealproposal',
name='billing_branch_launcher',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='billing_branch_launcher', to='clients.CoffeeCompany'),
),
迁移 8 看起来像这样
class Migration(migrations.Migration):
dependencies = [
('coffeedeals', '0007_auto_20190315_1642'),
('schemas', '0003_dynamicpackingtype')
]
def run(app, schema_editor):
bulk_proposals = md.DealProposal.active.filter(
data__negotiation__packing='bulk',
data__negotiation__packing_type__isnull=False)
for proposal in bulk_proposals:
del proposal.data['negotiation']['packing_type']
proposal.save()
operations = [migrations.RunPython(run, atomic=True)]
我该如何解决?
我建议安装 python 库
django-test-without-migrations
那么迁移文件错误不会影响测试。
pip install django-test-without-migrations
添加到INSTALLED_APPS (settings.py)
Then run :
python manage.py test --nomigrations
我正在尝试测试 Django 应用程序,但是当我 运行 python manager.py 测试时我遇到了这个错误
django.db.utils.ProgrammingError: column deals_dealproposal.billing_branch_launcher_id does not exist
它发生在
File "/migrations/0008_dynamicpackingtype.py", line 18, in run
for proposal in bulk_proposals:
在这一点上,billing_branch_launcher 并不真正存在,它是在迁移 27
中创建的migrations.AddField(
model_name='dealproposal',
name='billing_branch_launcher',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='billing_branch_launcher', to='clients.CoffeeCompany'),
),
迁移 8 看起来像这样
class Migration(migrations.Migration):
dependencies = [
('coffeedeals', '0007_auto_20190315_1642'),
('schemas', '0003_dynamicpackingtype')
]
def run(app, schema_editor):
bulk_proposals = md.DealProposal.active.filter(
data__negotiation__packing='bulk',
data__negotiation__packing_type__isnull=False)
for proposal in bulk_proposals:
del proposal.data['negotiation']['packing_type']
proposal.save()
operations = [migrations.RunPython(run, atomic=True)]
我该如何解决?
我建议安装 python 库
django-test-without-migrations
那么迁移文件错误不会影响测试。
pip install django-test-without-migrations
添加到INSTALLED_APPS (settings.py)
Then run :
python manage.py test --nomigrations