Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django get_col method not implmented when trying to do createsuperuser #120

Open
madhu72 opened this issue Jul 26, 2018 · 2 comments
Open

Comments

@madhu72
Copy link

madhu72 commented Jul 26, 2018

Defined Custom User Model for Cassandra based authentication:

    class CustomUser(DjangoCassandraModel):
            userid = cassandra_columns.UUID(primary_key=True , default=uuid.uuid4,db_field='userid')
            username = cassandra_columns.Text(required=True)
            password = cassandra_columns.Text(required=True)
            email = cassandra_columns.Text(primary_key=True,required=True)
            first_name =  cassandra_columns.Text(max_length=30,required=False)
            last_name =  cassandra_columns.Text(max_length=30,required=False)
            is_staff = cassandra_columns.Boolean(default=False)
            is_active = cassandra_columns.Boolean(default=True)
            is_anonymous = cassandra_columns.Boolean(default=False)
            is_authenticated = cassandra_columns.Boolean(default=False)

            def __str__(self):
                return self.email

            def get_by_natural_key(self, username):
                return self.get(**{self.USERNAME_FIELD: username})

            objects = UserManager()
            USERNAME_FIELD = 'email'
            REQUIRED_FIELDS = []
            

            class Meta:
                get_pk_field =  'userid'
                db_table = "amf_user_authentication"
                verbose_name = 'user'
                verbose_name_plural = 'users'

            def get_full_name(self):
                '''
                Returns the first_name plus the last_name, with a space in between.
                '''
                full_name = '%s %s' % (self.first_name, self.last_name)
                return full_name.strip()

            def get_short_name(self):
                '''
                Returns the short name for the user.
                '''
                return self.first_name

            def email_user(self, subject, message, from_email=None, **kwargs):
                '''
                Sends an email to this User.
                '''
                send_mail(subject, message, from_email, [self.email], **kwargs)

When I tried to createsuperuser after done with sync_cassandra I am getting following exception:

Traceback (most recent call last):
File "manage.py", line 15, in
execute_from_command_line(sys.argv)
File "D:\py3sbpoc\env\lib\site-packages\django\core\management_init_.py", line 371, in execute_from_command_line
utility.execute()
File "D:\py3sbpoc\env\lib\site-packages\django\core\management_init_.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\py3sbpoc\env\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\py3sbpoc\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 59, in execute
return super().execute(*args, **options)
File "D:\py3sbpoc\env\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args, options)
File "D:\py3sbpoc\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 117, in handle
self.UserModel._default_manager.db_manager(database).get_by_natural_key(username)
File "D:\py3sbpoc\sbpoc\dashboard\models.py", line 43, in get_by_natural_key
return self.get(
{self.model.USERNAME_FIELD: username})
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\query.py", line 394, in get
clone = self.filter(*args, **kwargs)
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\query.py", line 836, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\query.py", line 854, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\sql\query.py", line 1253, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\sql\query.py", line 1277, in _add_q
split_subq=split_subq,
File "D:\py3sbpoc\env\lib\site-packages\django\db\models\sql\query.py", line 1213, in build_filter
col = targets[0].get_col(alias, join_info.final_field)
File "D:\py3sbpoc\env\lib\site-packages\django_cassandra_engine\models\django_field_methods.py", line 251, in get_col
raise NotImplementedError(NOT_IMPL_MSG)
NotImplementedError: Method not available on Cassandra model fields

@oneandonlyonebutyou
Copy link

Any Updates

@r4fek
Copy link
Owner

r4fek commented Jun 10, 2021

django-cassandra-engine does not support Django auth module. It's on my TODO list though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants