我想从django.contrib.sites
项目中删除django
。
当我尝试删除时,我在启动服务器时遇到以下错误:
/usr/local/lib/python3.5/site-packages/django/db/models/fields/subclassing.py:22: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.
web_1 | RemovedInDjango110Warning)
web_1 |
web_1 | /usr/local/lib/python3.5/site-packages/django/db/models/fields/subclassing.py:22: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.
web_1 | RemovedInDjango110Warning)
web_1 |
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
web_1 | Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f154e979048>
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
web_1 | fn(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
web_1 | self.check_migrations()
web_1 | File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 163, in check_migrations
web_1 | executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
web_1 | File "/usr/local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 20, in __init__
web_1 | self.loader = MigrationLoader(self.connection)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 49, in __init__
web_1 | self.build_graph()
web_1 | File "/usr/local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 306, in build_graph
web_1 | _reraise_missing_dependency(migration, parent, e)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 276, in _reraise_missing_dependency
web_1 | raise exc
web_1 | File "/usr/local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 302, in build_graph
web_1 | self.graph.add_dependency(migration, key, parent)
web_1 | File "/usr/local/lib/python3.5/site-packages/django/db/migrations/graph.py", line 126, in add_dependency
web_1 | parent
web_1 | django.db.migrations.exceptions.NodeNotFoundError: Migration services.0001_initial dependencies reference nonexistent parent node ('sites', '0002_alter_domain_unique')
只有我在项目中所做的修改是,settings.py
我添加了以下信息:
SITE_ID = 1
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites'
]
执行以下命令后,在管理页面中查看结果:
python manage.py makemigrations
python manage.py migrate
现在,当我从设置中删除配置并运行makemigrations和migrate命令时,我得到了上述错误。
我正在使用python:3.5
和Django:1.9
与docker
。
答案 0 :(得分:1)
似乎是我自己解决的。我已经做了以下事情来解决它:
从$POST_ID
settings.py
SITE_ID = 1
块的和‘django.contrib.sites'
INSTALLED_APPS
从应用内的迁移文件夹中删除了自动生成的文件(我导入的应用INSTALLED_APPS = [
‘django.contrib.sites'
]
)。
重新运行django.contrib.sites Models
和makemigrations
命令。
一切都很好。
感谢。