4

I am running Debian server with Django and Cassandra. I am not able to create the admin user via command:

python manage.py createsuperuser

Running the command causes an error:

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

The synchronization works fine - the keyspace and tables were created according to model.

Question

How can I get rid of this error and make the command work?

Version information

  • Debian GNU/Linux 8.6 (jessie)
  • 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
            }
        }
    }
}

Full traceback

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]....)">
karelok
  • 301
  • 2
  • 9

2 Answers2

1

Django Cassandra Engine v1.7.0 (As of Sep 16, 2022) does not support the user model stored in Cassandra (auth module).

Workaround to this is a second database for the user model.

Amax
  • 47
  • 8
karelok
  • 301
  • 2
  • 9
0

We can not use:

python manage.py createsuperuser using cassandra

It does not work with the default django model.

You need to use an external library for the same.

Please read document on data-stax or at this link: https://pypi.python.org/pypi/django-cassandra-engine/

jwpfox
  • 5,124
  • 11
  • 45
  • 42
sanjusci
  • 187
  • 1
  • 9
  • While this may answer the question, it is better to explain the essential parts of the answer instead of link only. For example attaching relevant parts behind the link as quotation. – pirho Dec 08 '17 at 11:48