gpt4 book ai didi

python - Django / Cassandra : can not createsuperuser

转载 作者:太空宇宙 更新时间:2023-11-04 05:16:43 28 4
gpt4 key购买 nike

我正在使用 Django 和 Cassandra 运行 Debian 服务器。我无法通过命令创建管理员用户:

python manage.py createsuperuser

运行命令导致错误:

cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:260 no viable           alternative at input '.' (...auth_user.date_joined FROM auth_user WHERE [auth_user]....)">

同步工作正常 - 键空间和表是根据模型创建的。

问题

我怎样才能摆脱这个错误并使命令工作?

版本信息

  • Debian GNU/Linux 8.6(杰西)
  • python 2.7.9
  • Django 1.10.5
  • Cassandra 3.0.9

Django: settings.py

# Application definition

INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django_cassandra_engine',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django_cassandra_engine',
'NAME': 'mydb',
'TEST_NAME': 'test_db',
'HOST': 'xx.xx.xx.xx',
'OPTIONS': {
'replication': {
'strategy_class': 'SimpleStrategy',
'replication_factor': 1
}
}
}
}

完整追溯

Not checking migrations as it is not possible to access/create the django_migrations table.
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute
return super(Command, self).execute(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 96, in handle
default_username = get_default_username()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 148, in get_default_username
auth_app.User._default_manager.get(username=default_username)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 379, in get
num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 238, in __len__
self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django_cassandra_engine/utils.py", line 47, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django_cassandra_engine/connection.py", line 13, in execute
return self.connection.execute(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_cassandra_engine/connection.py", line 88, in execute
return self.session.execute(qs, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1998, in execute
return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 3781, in result
raise self._final_exception
cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:260 no viable alternative at input '.' (...auth_user.date_joined FROM auth_user WHERE [auth_user]....)">

最佳答案

Django Cassandra Engine v1.7.0(截至 2022 年 9 月 16 日)不支持存储在 Cassandra 中的用户模型(auth 模块)。

解决方法是为用户模型使用第二个数据库。

关于python - Django / Cassandra : can not createsuperuser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41534591/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com