unable to create superuser in python Django - django

I have read questions in Stackoverflow and googled, but no luck.
I am trying to create a superuser in pycharm(manage.py createsuperuser
) but got below error:
"cassandra.protocol.SyntaxException: "
Not checking migrations as it is not possible to access/create the django_migrations table.
Traceback (most recent call last):
File "C:\Users\skum\PQP_Bridge\manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 63, in execute
return super(Command, self).execute(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 96, in handle
default_username = get_default_username()
File "C:\Python27\lib\site-packages\django\contrib\auth\management\__init__.py", line 148, in get_default_username
auth_app.User._default_manager.get(username=default_username)
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 374, in get
num = len(clone)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 232, in __len__
self._fetch_all()
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 894, in execute_sql
raise original_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]....)">
what am I doing wrong?
I am using Cassandra 3.0, Python Django 1.11.4, and pycharm.

We can not use: python manage.py createsuperuser using Cassandra It do not work with default django model. You need to use external library for the same. user module does not work with Cassandra by default
Please read document on data-stax or below given link. https://pypi.python.org/pypi/django-cassandra-engine/

Related

Upgrade geodjango app to django1.9

I am trying to upgrade my django project from django1.8.8 to django1.9.2
Right now I encounter a problem when running my tests with django1.9.2:
python manage.py test
This gives me the following error
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/test/runner.py", line 532, in run_tests
old_config = self.setup_databases()
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/test/runner.py", line 482, in setup_databases
self.parallel, **kwargs
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/test/runner.py", line 726, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/db/backends/base/creation.py", line 70, in create_test_db
run_syncdb=True,
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 119, in call_command
return command.execute(*args, **defaults)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 87, in handle
connection.prepare_database()
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 25, in prepare_database
cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis")
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/ilse/myvenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.InternalError: PostGIS is already installed in schema 'public', uninstall it first
In django1.8 everything works as expected.
Are there any changes in django1.9 and postgis I am not aware of?
It may be due to postgis. Please make sure postgres have the postgis extension.
I could solve this by a hard reset of the databse.

Travis CI with Django 1.7.1 has operational error

I ask you about CI(Continuous Integration).
For using this service, I choose travis CI.
and problem is that in local test, there is no problem. but on travis I have error about operational error in db.
The reason in local is that there is no add to my app in installed app section.
I fixed it, but travis could not find my app, so it shows operational errors again and again.
I use Django 1.7.1 versions.
Is there anyone suggests me solutions??
I posted travis build log
$ python manage.py test
Creating test database for alias 'default'...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/commands/test.py", line 71, in execute
super(Command, self).execute(*args, **options)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/commands/test.py", line 88, in handle
failures = test_runner.run_tests(test_labels)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/test/runner.py", line 147, in run_tests
old_config = self.setup_databases()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/test/runner.py", line 109, in setup_databases
return setup_databases(self.verbosity, self.interactive, **kwargs)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/test/runner.py", line 299, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/creation.py", line 385, in create_test_db
self.connection._test_serialized_contents = self.serialize_db_to_string()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/creation.py", line 421, in serialize_db_to_string
serializers.serialize("json", get_objects(), indent=None, stream=out)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/serializers/__init__.py", line 128, in serialize
s.serialize(queryset, **options)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/serializers/base.py", line 52, in serialize
for obj in queryset:
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/creation.py", line 417, in get_objects
for obj in queryset.iterator():
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/models/query.py", line 265, in iterator
for row in compiler.results_iter():
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 485, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: users_user
The command "python manage.py test" exited with 1.
and here is my travis.yml
language: python
python:
- '2.7'
install:
- pip install -r requirements.txt
script:
- python manage.py migrate
- python manage.py test

moving django site to another server

I want to move my django site to another machine.
(I want to start with empty DB)
I thought i'll be done with the following steps.
copy all files
setup all tools(django,python,..etc)
run syncdb
When I run manage.py syncdb, it complains some table(such as django_content_type) doesn't exist.
I looked at the DB, indeed there are no tables in the DB.
I tried recreate project(startproject) or recreate app(startapp).
(But they fail because the project or app name is already taken.)
What should I do?
The reason I can think of is mysql being upgraded to 5.5.27 (default to innodb)
$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 231, in execute
self.validate()
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name, True)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/ubuntu/Documents/aLittleArtist/django/gallery/models.py", line 152, in <module>
ALBUM_IMAGE_TYPE = ContentType.objects.get(app_label="gallery", model="AlbumImage")
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/manager.py", line 131, in get
return self.get_query_set().get(*args, **kwargs)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 361, in get
num = len(clone)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 85, in __len__
self._result_cache = list(self.iterator())
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 291, in iterator
for row in compiler.results_iter():
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 763, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
return self.cursor.execute(query, args)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.DatabaseError: (1146, "Table 'gallery_db.django_content_type' doesn't exist")
ALBUM_IMAGE_TYPE = ContentType.objects.get(app_label="gallery", model="AlbumImage")
This line was the culprit.
seems like the above line attempts to do DB query before any DB table is created.
I removed the line and relevant code and let syncdb run. and did migrate with south.

django psycopg2 and postgresql insertion error

I'm having trouble adding any data to my database. It lets me modify entries in tables, but any action that will create a new row or new column in a database is mysteriously failing. Here is the stack trace:
Traceback (most recent call last):
File "manage.py", line 25, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/management/commands/migrate.py", line 107, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/__init__.py", line 219, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 235, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 134, in migrate
self.done_migrate(migration, database)
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 113, in done_migrate
self.record(migration, database)
File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 280, in record
record.save()
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/base.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/base.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/query.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/sql/compiler.py", line 910, in execute_sql
cursor.execute(sql, params)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: syntax error at or near "RETURNING" at character 171
It was working fine until I migrated databases to another server. Now I'm having all sorts of trouble and I'm unsure what to do. Also, this seems to happen for South as well if trying to add a field to the database. Curiously, modifying existing objects / columns in the database succeeds without failure. I'm really unsure what to do and would love any assistance.
8.1 doesn't support the RETURNING clause. So upgrade your database version to the current stable release.
8.1 doesn't support RETURNING ids of inserted objects so you need to disable it.
from django.db import connection
##just before insert statement
connection.features.can_return_id_from_insert = False
###some insert statement

ERROR on -$ dotcloud run myapp.www python current/myapp/manage.py syncdb

Django noob. Can you tell me what I am doing wrong here? I looked this up on google, and the closest issue I found was this and this -- but couldn't figure it out.
Is this a password issue? I have the mysql password on my settings.py
I appreciate your help.
j#ime:~/dotcloud$ dotcloud run jims.www python current/jims/manage.py syncdb
# python current/jims/manage.py syncdb
Traceback (most recent call last):
File "current/jims/manage.py", line 14, in <module>
execute_manager(settings)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/validation.py", line 102, in get_validation_errors
connection.validation.validate_field(e, opts, f)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/mysql/validation.py", line 14, in validate_field
db_version = self.connection.get_server_version()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 338, in get_server_version
self.cursor()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 322, in _cursor
self.connection = Database.connect(**kwargs)
File "/home/dotcloud/env/lib/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/home/dotcloud/env/lib/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'jims'#'ip-10-68-47-216.ec2.internal' (using password: YES)")
Abort.