python - Django 1.8 programming error: relation auth_user doesn't exist when running test -
i've read existing answer problem in stackoverflow. none worked me. when run manage.py test
, following, although website run fine!
$ ./manage.py test --verbosity=3 manage.py test --verbosity=3 nosetests --with-coverage --cover-package=project.iobserve.forms,project.iobserve.models,project.iobserve.views --verbosity=3 nose.config: info: ignoring files matching ['^\\.', '^_', '^setup\\.py$'] nose.plugins.cover: info: coverage report include packages: ['project.iobserve.forms', 'project.iobserve.models', 'project.iobserve.views'] creating test database alias 'default' ('test_iobserve')... got error creating test database: database "test_iobserve" exists type 'yes' if try deleting test database 'test_iobserve', or 'no' cancel: yes destroying old test database 'default'... operations perform: synchronize unmigrated apps: mptt, djangobower, iobserve, staticfiles, twitter, messages, leaflet, allauth, facebook, multiselectfield, django_nose, rest_framework, honeypot apply migrations: account, sessions, admin, sites, auth, contenttypes, socialaccount synchronizing apps without migrations: running pre-migrate handlers application admin running pre-migrate handlers application contenttypes running pre-migrate handlers application sites running pre-migrate handlers application auth running pre-migrate handlers application sessions running pre-migrate handlers application rest_framework running pre-migrate handlers application mptt running pre-migrate handlers application djangobower running pre-migrate handlers application honeypot running pre-migrate handlers application leaflet running pre-migrate handlers application allauth running pre-migrate handlers application account running pre-migrate handlers application socialaccount running pre-migrate handlers application twitter running pre-migrate handlers application facebook running pre-migrate handlers application iobserve creating tables... creating table iobserve_person creating table iobserve_bibliographicreference creating table user_profile creating table iobserve_coordinates creating table iobserve_observingsite creating table iobserve_astronomicalorganisation creating table iobserve_building creating table iobserve_dome creating table iobserve_tool creating table iobserve_observingtool creating table iobserve_telescope creating table iobserve_toolcomponent creating table iobserve_mirror creating table iobserve_astronomicalcoordinates creating table iobserve_alias creating table iobserve_objecttype creating table iobserve_astronomicalflux creating table iobserve_astronomicalobject running deferred sql... traceback (most recent call last): file "manage.py", line 7, in <module> execute_from_command_line(sys.argv) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/users/onekiloparsec/.virtualenvs/iobs-debug/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 "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute super(command, self).execute(*args, **options) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle failures = test_runner.run_tests(test_labels) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django_nose/runner.py", line 350, in run_tests result = self.run_suite(nose_argv) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django_nose/runner.py", line 297, in run_suite addplugins=plugins_to_add) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/nose/core.py", line 121, in __init__ **extra_args) file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/unittest/main.py", line 95, in __init__ self.runtests() file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/nose/core.py", line 207, in runtests result = self.testrunner.run(self.test) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/nose/core.py", line 50, in run wrapper = self.config.plugins.preparetest(test) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__ return self.call(*arg, **kw) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple result = meth(*arg, **kw) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django_nose/plugin.py", line 76, in preparetest self.old_names = self.runner.setup_databases() file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django_nose/runner.py", line 533, in setup_databases return super(nosetestsuiterunner, self).setup_databases() file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/test/runner.py", line 166, in setup_databases **kwargs file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/test/runner.py", line 370, in setup_databases serialize=connection.settings_dict.get("test", {}).get("serialize", true), file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 368, in create_test_db test_flush=not keepdb, file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command return command.execute(*args, **defaults) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 179, in handle created_models = self.sync_apps(connection, executor.loader.unmigrated_apps) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 317, in sync_apps cursor.execute(statement) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) file "/users/onekiloparsec/.virtualenvs/iobs-debug/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) django.db.utils.programmingerror: relation "auth_user" not exist
the problematic line relationship between userprofile , user in models. below userprofile model. ran makemigrations
, migrate
individually, sequentially, etc etc. when run tests, fails. have no clue. appreciated!
from django.conf import settings django.db import models allauth.account.models import emailaddress allauth.socialaccount.models import socialaccount import hashlib class userprofile(models.model): class meta: db_table = 'user_profile' app_label = 'iobserve' user = models.onetoonefield(settings.auth_user_model, related_name='profile') def __unicode__(self): return "{}'s profile".format(self.user.username) def account_verified(self): if self.user.is_authenticated: result = emailaddress.objects.filter(email=self.user.email) if len(result): return result[0].verified return false def profile_image_url(self): fb_uid = socialaccount.objects.filter(user_id=self.user.id, provider='facebook') if len(fb_uid): return "http://graph.facebook.com/{}/picture?width=40&height=40".format(fb_uid[0].uid) return "http://www.gravatar.com/avatar/{}?s=40".format(hashlib.md5(self.user.email).hexdigest())
your iobserve
app doesn't have migrations, , can't have relation, such onetoonefield
, unmigrated app migrated app.
you need run manage.py makemigrations iobserve
create initial migrations iobserve
app. when initial migrations exist, manage.py makemigrations
without app labels create new migrations app.
Comments
Post a Comment