【发布时间】:2016-04-05 15:08:43
【问题描述】:
我见过
How to use ArrayField in Django using PostgreSQL DB?
但是当我打电话时我得到的当前错误发生
python manage.py migrate
我得到了错误
` Applying game.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/migrate.py", line 221, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/Library/Python/2.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 "/Library/Python/2.7/site-packages/django/db/migrations/executor.py", line 147, in apply_migration
state = migration.apply(state, schema_editor)
File "/Library/Python/2.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 "/Library/Python/2.7/site-packages/django/db/migrations/operations/models.py", line 59, in database_forwards
schema_editor.create_model(model)
File "/Library/Python/2.7/site-packages/django/db/backends/base/schema.py", line 282, in create_model
self.execute(sql, params or None)
File "/Library/Python/2.7/site-packages/django/db/backends/base/schema.py", line 107, in execute
cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Python/2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py", line 316, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: near "[10]": syntax error`
咨询后 https://docs.djangoproject.com/en/1.9/ref/contrib/postgres/fields/ 我仍然无法弄清楚如何在 OS X 上使用 Django 1.8 中可用的 PostgresSQL 字段。这是我的第一个 Django 应用程序,因此将不胜感激。谢谢!
settings.py 的数据库看起来像
`DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}`
【问题讨论】:
-
但是你需要告诉我们你是如何使用
ArrayField的?没有任何代码,我们无法猜测您做错了什么。 -
您能否向我们展示您的
settings.py部分以及您的数据库设置?当然没有用户名/密码。从"/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py"看来,您使用了错误的数据库后端驱动程序。 -
我见过这个,但我只是在放入一个 ArrayField 后才得到这个错误。 stackoverflow.com/questions/33270297/… 除了
INSTALLED_APPS = ( 'django.contrib.admin', ... ... ... 'django.contrib.postgres', 'game', ),我在settings.py中什么都没改变
标签: django postgresql