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.
Related
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/
I am trying to run django's test suite for my application with two databases: one using postgres and the other using POSTGIS. Here is my DATABASES configuration:
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
...},
'POSTGIS': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
...}
When I run python manage.py test app I am prompted to delete an old test database, and when I say yes I get the following error:
Destroying old 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/ubuntu/yes/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/test/runner.py", line 532, in run_tests
old_config = self.setup_databases()
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/test/runner.py", line 482, in setup_databases
self.parallel, **kwargs
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/test/runner.py", line 726, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 70, in create_test_db
run_syncdb=True,
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/__init__.py", line 119, in call_command
return command.execute(*args, **defaults)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 172, in handle
self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 285, in sync_apps
editor.create_model(model)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 235, in create_model
definition, extra_params = self.column_sql(model, field)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 134, in column_sql
db_params = field.db_parameters(connection=self.connection)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 636, in db_parameters
type_string = self.db_type(connection)
File "/home/ubuntu/yes/lib/python2.7/site-packages/django/contrib/gis/db/models/fields.py", line 120, in db_type
return connection.ops.geo_db_type(self)
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
Which version of Django are you using?
When you made the database changes, prior to anything else, did you use the appropriate command to update the databases and relationships to them, i.e., syncdb or migrate?
Answering those two questions will help diagnose the problem. Thanks!
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
In my apps settings.py file (then made available in django.conf.settings) I have specified:
DATABASES = {'default': dj_database_url.parse(os.environ['DATABASE']),
'secondary': dj_database_url.parse(os.environ['SECONDARY_DATABASE'])}
SOUTH_TESTS_MIGRATE = True
But running my tests using ./manage.py test app_name runs the migrations for the default database and creates some of the tables for the secondary database before failing with:
Creating test database for alias 'secondary' ('test_secondary')...
Syncing...
Creating tables ...
Creating table auth_permission
...
Creating table django_admin_log
Installing custom SQL ...
Installing indexes ...
Migrating...
Traceback (most recent call last):
File "./manage.py", line 18, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 381, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 49, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/test/simple.py", line 381, in run_tests
old_config = self.setup_databases()
File "/usr/local/venv/local/lib/python2.7/site-packages/django/test/simple.py", line 317, in setup_databases
self.verbosity, autoclobber=not self.interactive)
File "/usr/local/venv/local/lib/python2.7/site-packages/south/hacks/django_1_0.py", line 100, in wrapper
f(*args, **kwargs)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/db/backends/creation.py", line 271, in create_test_db
load_initial_data=False)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 149, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/usr/local/venv/local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 99, in handle_noargs
management.call_command('migrate', **options)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 149, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/venv/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/venv/local/lib/python2.7/site-packages/south/migration/__init__.py", line 171, in migrate_app
south.db.db = south.db.dbs[database]
KeyError: 'secondary'
When rebuilding my indices via ./manage.py rebuild_index I get this error:
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/haystack/management/commands/rebuild_index.py", line 13, in handle
call_command('clear_index', **options)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/haystack/management/commands/clear_index.py", line 38, in handle
sb.clear()
File "/Library/Python/2.6/site-packages/haystack/backends/whoosh_backend.py", line 197, in clear
self.setup()
File "/Library/Python/2.6/site-packages/haystack/backends/whoosh_backend.py", line 105, in setup
self.index = self.storage.open_index(schema=self.schema)
File "/Library/Python/2.6/site-packages/Whoosh-0.3.18-py2.6.egg/whoosh/filedb/filestore.py", line 48, in open_index
File "/Library/Python/2.6/site-packages/Whoosh-0.3.18-py2.6.egg/whoosh/filedb/fileindex.py", line 94, in __init__
File "/Library/Python/2.6/site-packages/Whoosh-0.3.18-py2.6.egg/whoosh/filedb/fileindex.py", line 173, in _read
IndexError: Index was created on an architecture with different data sizes
You have probably downgraded from whoosh 1.0.0 to 0.3.18, but there are some buggy index files already created at the path you defined by HAYSTACK_WHOOSH_PATH. Just make that directory empty and try again.