Travis CI with Django 1.7.1 has operational error - django

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

Related

How to fix Jenkins error. no such table: users_user

Not sure where to start.
I just want Jenkins to run tests via python manage.py test
In my VirtualEnv build step I run migrations after installing necessary packages. I then try to run python manage.py test which cannot complete.
Output:
[...]
Applying auth.0012_alter_user_first_name_max_length... OK
Applying users.0001_initial... OK
Applying admin.0001_initial... OK
[...]
Part of Traceback (starting # test command):
+ python manage.py test
/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/environ/environ.py:628: UserWarning: /var/lib/jenkins/workspace/New_Performance_Realm/speedrealm/.env doesn't exist - if you're not configuring your environment separately, create one.
warnings.warn(
Creating test database for alias 'default'...
Traceback (most recent call last):
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 421, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: no such table: users_user
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/commands/test.py", line 55, in handle
failures = test_runner.run_tests(test_labels)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/test/runner.py", line 725, in run_tests
old_config = self.setup_databases(aliases=databases)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/test/runner.py", line 643, in setup_databases
return _setup_databases(
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/test/utils.py", line 179, in setup_databases
connection.creation.create_test_db(
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/base/creation.py", line 74, in create_test_db
call_command(
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/__init__.py", line 181, in call_command
return command.execute(*args, **defaults)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 214, in handle
self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 353, in sync_apps
self.stdout.write(' Running deferred SQL...')
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/sqlite3/schema.py", line 35, in __exit__
self.connection.check_constraints()
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 371, in check_constraints
cursor.execute(
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/var/lib/jenkins/shiningpanda/jobs/1d61c5c6/virtualenvs/d41d8cd9/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 421, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: no such table: users_user
Build step 'Virtualenv Builder' marked build as failure
Finished: FAILURE
Following the traceback it appears its a sqlite3 error which is what the test db instance is.
I looked at the test db and verified a users_user table has been created. Why is Jenkins giving me this error? I also use MySQL but I get a permission denied error.
This all works locally btw, deleteing the db, re-creating, running migrations, and running the test.
As of now, I found there were multiple errors but seemed hidden. I ran one test at a time and the first test had an actual failure. I can update this when I edit all of the tests, to verify if this is indeed the problem.

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.

django dumpdata => load on heroku

I'm trying to load the data from my sqlite database to heroku postgres but it is not working.
First I ran:
manage.py dumpdata --indent 1 > data.json
and then I tried to upload it to heroku with (after I committed the file to heroku):
heroku run python manage.py loaddata data.json
but it just didn't work...
it gave me errors:
Running `python manage.py loaddata data.json` attached to terminal... up, run.92
01
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/_
_init__.py", line 385, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/_
_init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/b
ase.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/b
ase.py", line 338, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/c
ommands/loaddata.py", line 61, in handle
self.loaddata(fixture_labels)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/c
ommands/loaddata.py", line 91, in loaddata
self.load_label(fixture_label)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/c
ommands/loaddata.py", line 148, in load_label
obj.save(using=self.using)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/serializers/
base.py", line 173, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py
", line 617, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, upda
te_fields)
File "/app/.heroku/python/lib/python2.7/sitepackages/django/db/models/base.py
", line 679, in _save_table
forced_update)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/base.py
", line 723, in _do_update
return filtered._update(values) > 0
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.p
y", line 600, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/com
piler.py", line 1004, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/com
piler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils
.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils
.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: Problem installing fixture '/app/data.json': C
ould not load contenttypes.ContentType(pk=1): relation "django_content_type" does not exist
LINE 1: UPDATE "django_content_type" SET "name" = 'log entry', "app_...
What may be the problem?
The end of the stacktrace has the key:
relation "django_content_type" does not exist
LINE 1: UPDATE "django_content_type" SET "name" = 'log entry', "app_...
The table django_content_type does not exist. Try running the migrations:
heroku run python manage.py migrate
or, if you are using an old version:
heroku run python manage.py setupdb

Django-notifications won't sync

I'm trying to set up django-notifications in my app. I'm following the instructions to install it, which are pretty straight-forward: https://github.com/brantyoung/django-notifications#installation
When I run manage.py migrate notifications I get:
django.db.utils.ProgrammingError: (1146, "Table '{{database}}.notifications_notification' doesn't exist")
I'm at a loss.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 230, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 305, in migrate_many
result = self.migrate(migration, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 134, in migrate
result = self.run(migration, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 115, in run
return self.run_migration(migration, database)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 85, in run_migration
migration_function()
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/migration/migrators.py", line 61, in <lambda>
return (lambda: direction(orm))
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/notifications/migrations/0002_auto__add_field_notification_data.py", line 14, in forwards
keep_default=False)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/db/generic.py", line 47, in _cache_clear
return func(self, table, *args, **opts)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/db/generic.py", line 418, in add_column
self.execute(sql)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/south/db/generic.py", line 282, in execute
cursor.execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/util.py", line 69, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/MySQLdb/cursors.py", line 201, in execute
self.errorhandler(self, exc, value)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.ProgrammingError: (1146, "Table 'ownershipdb.notifications_notification' doesn't exist")
You forget to run syncdb before migrating data. The table doesn't exists because it's syncdb that created it, not the migration.
Reference: http://south.readthedocs.org/en/latest/tutorial/part1.html
(If this fails complaining that south_migrationhistory does not exist, you forgot to run syncdb after you installed South.)

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.