开发者社区> 问答> 正文

django 报错求大神指教?报错

django执行python manage.py migrate后出现报错

Operations to perform:
  Synchronize unmigrated apps: staticfiles, messages
  Apply all migrations: sessions, admin, auth, contenttypes, books, foodsite
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying foodsite.0006_bookfood_num...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 222, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/usr/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 "/usr/lib/python2.7/site-packages/django/db/migrations/executor.py", line 148, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/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 "/usr/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards
    field,
  File "/usr/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 43, in add_field
    super(DatabaseSchemaEditor, self).add_field(model, field)
  File "/usr/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 384, in add_field
    definition, params = self.column_sql(model, field, include_default=True)
  File "/usr/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 146, in column_sql
    default_value = self.effective_default(field)
  File "/usr/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 211, in effective_default
    default = field.get_db_prep_save(default, self.connection)
  File "/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1626, in get_db_prep_save
    return connection.ops.value_to_db_decimal(self.to_python(value),
  File "/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1602, in to_python
    params={'value': value},
django.core.exceptions.ValidationError: [u"'' value must be a decimal number."]

展开
收起
爱吃鱼的程序员 2020-06-08 16:21:50 539 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    ''valuemustbeadecimalnumber

    错误很明显,它也

    这个报错是说value值必须是个小数,你debug下看看是不是models里面有字段定义出错

    谢谢,问题已经解决了,我把migrations和 数据库的记录迁移记录清空,重新迁移了

     

    2020-06-08 16:22:09
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载