Python+Django+Ansible Playbook自动化运维项目的问题

python manage.py createsuperuserUsername (leave blank to use 'root'): rootEmail address: 123@126.comPassword:Password (again):Superuser created successfully.(CMDB) [root@zhenai imoocc]# python manage.py makemigrations\> ^C(CMDB) [root@zhenai imoocc]# python manage.py makemigrationsMigrations for 'operations':  0001_initial.py:    - Create model MachineOperationsInfoMigrations for 'scanhosts':  0001_initial.py:    - Create model HostLoginifoMigrations for 'xadmin':  0001_initial.py:    - Create model Bookmark    - Create model Log    - Create model UserSettings    - Create model UserWidgetMigrations for 'detail':  0001_initial.py:    - Create model CabinetInfo    - Create model ConnectionInfo    - Create model NetConnectionInfo    - Create model NetWorkInfo    - Create model OtherMachineInfo    - Create model PhysicalServerInfo    - Create model StatisticsRecord    - Create model VirtualServerInfo    - Add field dev_info to netconnectioninfoMigrations for 'users':  0001_initial.py:    - Create model UserInfo
(CMDB) [root@zhenai imoocc]# python manage.py migrateOperations to perform:  Synchronize unmigrated apps: staticfiles, django_crontab, messages, crispy_forms  Apply all migrations: operations, xadmin, users, sessions, admin, scanhosts, detail, auth, contenttypesSynchronizing apps without migrations:  Creating tables...    Running deferred SQL...  Installing custom SQL...Running migrations:  Rendering model states... DONE  Applying contenttypes.0001_initial... OK  Applying auth.0001_initial... OK  Applying admin.0001_initial... OK  Applying contenttypes.0002_remove_content_type_name... OK  Applying auth.0002_alter_permission_name_max_length... OK  Applying auth.0003_alter_user_email_max_length... OK  Applying auth.0004_alter_user_username_opts... OK  Applying auth.0005_alter_user_last_login_null... OK  Applying auth.0006_require_contenttypes_0002... OK  Applying detail.0001_initial... OK  Applying operations.0001_initial... OK  Applying scanhosts.0001_initial... OK  Applying sessions.0001_initial... OK  Applying users.0001_initial... OK  Applying xadmin.0001_initial...Traceback (most recent call last):  File "manage.py", line 15, in <module>    execute_from_command_line(sys.argv)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line    utility.execute()  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute    self.fetch_command(subcommand).run_from_argv(self.argv)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv    self.execute(*args, **cmd_options)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute    output = self.handle(*args, **options)  File "/root/.pyenv/versions/CMDB/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 "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/migrations/executor.py", line 147, in apply_migration    state = migration.apply(state, schema_editor)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/migrations/migration.py", line 115, in apply    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 59, in database_forwards    schema_editor.create_model(model)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 236, in create_model    definition, extra_params = self.column_sql(model, field)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 135, in column_sql    db_params = field.db_parameters(connection=self.connection)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1992, in db_parameters    return {"type": self.db_type(connection), "check": []}  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1983, in db_type    rel_field = self.related_field  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1886, in related_field    return self.foreign_related_fields[0]  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1620, in foreign_related_fields    return tuple(rhs_field for lhs_field, rhs_field in self.related_fields)  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1607, in related_fields    self._related_fields = self.resolve_related_fields()  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1600, in resolve_related_fields    else self.rel.to._meta.get_field(to_field_name))  File "/root/.pyenv/versions/CMDB/lib/python2.7/site-packages/django/db/models/options.py", line 554, in get_field    raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name))django.core.exceptions.FieldDoesNotExist: ContentType has no field named <function SET_NULL at 0x7f435dedb7d0>

https://img3.mukewang.com/5ce3b46200012b7f11130580.jpg

https://img2.mukewang.com/5ce3b462000141a107620533.jpg

https://img1.mukewang.com/5ce3b4620001649411340587.jpg

前半段没有问题,到后面迁移时,出现错误;

系统环境:centos7

python环境:Python 2.7.16


一木浮生
浏览 1832回答 1
1回答

战渣渣

找到makemigrations出来的文件看一下里面有没有设置SET_NULL的,这个不存在的类型,贴出来这段代码看一下。
打开App,查看更多内容
随时随地看视频慕课网APP