Docker Django迁移命令类型错误

时间:2016-02-05 07:31:55

标签: python django postgresql docker

使用以下方法在docker-compose中执行migrate命令:

docker-compose run web python manage.py migrate

我收到以下错误:

#->docker-compose run web python manage.py migrate
/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.
  RemovedInDjango110Warning)

Operations to perform:
  Apply all migrations: default, admin, auth, user_profile, sessions, contenttypes
Running migrations:
  Rendering model states... DONE
  Applying user_profile.0006_auto_20160205_1127...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 200, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 92, in migrate
    self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 198, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/migration.py", line 123, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards
    field,
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 382, in add_field
    definition, params = self.column_sql(model, field, include_default=True)
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 145, in column_sql
    default_value = self.effective_default(field)
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 210, in effective_default
    default = field.get_db_prep_save(default, self.connection)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 728, in get_db_prep_save
    prepared=False)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 968, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 976, in get_prep_value
    return int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'

原因是什么?我是Django和Docker设置的新手。

0 个答案:

没有答案