Django / Cassandra:无法创建超级用户

Django / Cassandra: can not createsuperuser

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

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]....)">

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

问题

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

版本信息

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.0.2 不支持 Cassandra 中存储的用户模型(auth 模块)。

解决此问题的方法是为用户模型提供第二个数据库。

我们不能使用:

python manage.py createsuperuser using cassandra

它不适用于默认的 django 模型。

您需要为此使用外部库。

请阅读有关 data-stax 或此处 link 的文档: https://pypi.python.org/pypi/django-cassandra-engine/