我正在试图卸载一个名为
我继续从
django-cities
的应用程序,但在我的应用程序“places”中,我有一个称为Venue
的模型,在迁移0001_initial.py
中,该模型与django-cities
的cities.Subregion
模型有一个ForeingKey
。我继续从
INSTALLED_APPS
中删除 django-cities
,但是我收到了以下错误:Traceback (most recent call last):
File "/home/d/.virtualenvs/beplay/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/d/.virtualenvs/beplay/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
self.check_migrations()
File "/home/d/.virtualenvs/beplay/local/lib/python2.7/site-packages/django/core/management/base.py", line 422, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/d/.virtualenvs/beplay/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/d/.virtualenvs/beplay/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/home/d/.virtualenvs/beplay/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 274, in build_graph
raise exc
django.db.migrations.exceptions.NodeNotFoundError: Migration places.0001_initial dependencies reference nonexistent parent node (u'cities', u'0010_adjust_unique_attributes')
然后我删除了那些依赖项,卸载了 django-cities
,这样一切就正常了,但是如果其他人需要安装该项目,则 migrate
命令会引发以下错误:
ValueError: Related model u'cities.Subregion' cannot be resolved
因为我从requirements.txt
中删除了它,但它仍然在迁移0001_initial.py
中被引用:
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Venue',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
('name', models.CharField(max_length=255)),
('phone', models.CharField(blank=True, max_length=255, null=True)),
('mobile', models.CharField(blank=True, max_length=255, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('address', models.CharField(blank=True, max_length=255, null=True)),
('latitude', models.CharField(blank=True, max_length=100, null=True)),
('longitude', models.CharField(blank=True, max_length=100, null=True)),
('subregion', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities.Subregion')),
],
options={
'abstract': False,
},
),
]
然后我删除了这行:
('subregion', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities.Subregion')),
并且出现了另一个错误:
AttributeError: 'NoneType' object has no attribute 'is_relation'
我也试图从项目中删除所有 .pyc
文件,同时我谷歌了这个错误并找到了这个,但它没有给出答案。
有关此事的任何信息吗?
谢谢,对我的糟糕英语表示抱歉。