ValueError:无法引用参数值 <django.contrib.postgres.fields.jsonb.JsonAdapter
Posted
技术标签:
【中文标题】ValueError:无法引用参数值 <django.contrib.postgres.fields.jsonb.JsonAdapter【英文标题】:ValueError: Cannot quote parameter value <django.contrib.postgres.fields.jsonb.JsonAdapter 【发布时间】:2020-05-10 14:11:46 【问题描述】:当我尝试使用 python manage.py migrate 应用迁移时出现此错误。我正在使用 sqlite3。我的模型中有一个 JSONField。请任何想法如何解决这个问题。下面是整个异常的 sn-p。
Operations to perform:
Apply all migrations: account, admin, auth, blog, contenttypes, sessions, sites, small_small_hr, socialaccount
Running migrations:
Applying small_small_hr.0011_auto_20200124_1128...Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\hp\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\core\management\commands\migrate.py", line 234, in handle
fake_initial=fake_initial,
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\migrations\operations\fields.py", line 112, in database_forwards
field,
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\backends\sqlite3\schema.py", line 327, in add_field
self._remake_table(model, create_field=field)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\backends\sqlite3\schema.py", line 188, in _remake_table
self.effective_default(create_field)
File "C:\Users\hp\Anaconda3\lib\site-packages\django\db\backends\sqlite3\schema.py", line 64, in quote_value
raise ValueError("Cannot quote parameter value %r of type %s" % (value, type(value)))
ValueError: Cannot quote parameter value <django.contrib.postgres.fields.jsonb.JsonAdapter object at 0x00000207F3896708> of type <class 'django.contrib.postgres.fields.jsonb.JsonAdapter'>
【问题讨论】:
【参考方案1】:哎呀!我想我正在使用 SQlite 不支持的 Postgres 特定 JSONField。 与 PostgreSQL 不同,SQLite 本身不支持 JSON。更多信息可以在这里查看:https://medium.com/@philamersune/using-postgresql-jsonfield-in-sqlite-95ad4ad2e5f1
【讨论】:
以上是关于ValueError:无法引用参数值 <django.contrib.postgres.fields.jsonb.JsonAdapter的主要内容,如果未能解决你的问题,请参考以下文章
无法调用或分配具有右值引用作为参数的 std::function (Visual C++)
ValueError:无法处理 Python/MySQL 中的参数
PySpark - ValueError:无法将列转换为布尔值