Django:从 INSTALLED_APPS 中删除 django.contrib.sites 时出错
Django : Getting error while removing django.contrib.sites from INSTALLED_APPS
我想从我的 django
项目中删除 django.contrib.sites
。
当我尝试删除时,我在启动服务器时遇到以下错误:
/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
。
看来是自己解决了。以下是我为解决它所做的事情:
从 settings.py
中删除以下内容
SITE_ID = 1
和‘django.contrib.sites'
来自INSTALLED_APPS
块
INSTALLED_APPS = [
‘django.contrib.sites'
]
从应用程序中的 migrations 文件夹中删除了自动生成的文件(我在其中导入了应用程序 django.contrib.sites Models
)。
重新运行makemigrations
和migrate
命令。
一切正常。
谢谢。
我想从我的 django
项目中删除 django.contrib.sites
。
当我尝试删除时,我在启动服务器时遇到以下错误:
/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
。
看来是自己解决了。以下是我为解决它所做的事情:
从
中删除以下内容settings.py
SITE_ID = 1
和‘django.contrib.sites'
来自INSTALLED_APPS
块
INSTALLED_APPS = [
‘django.contrib.sites'
]
从应用程序中的 migrations 文件夹中删除了自动生成的文件(我在其中导入了应用程序
django.contrib.sites Models
)。重新运行
makemigrations
和migrate
命令。一切正常。
谢谢。