danfairs / django-lazysignup

django-lazysignup is a package designed to allow users to interact with a site as if they were authenticated users, but without signing up. At any time, they can convert their temporary user account to a real user account.
BSD 3-Clause "New" or "Revised" License
410 stars 89 forks source link

Migrate error: django.db.utils.ProgrammingError: relation "auth_user" does not exist #41

Open StErMi opened 10 years ago

StErMi commented 10 years ago

This is my current setup:

Django version: 1.6.1

I've installed django-lazysignup from pip I've configured everything

'lazysignup.backends.LazySignupBackend' to AUTHENTICATION_BACKENDS
'lazysignup' to INSTALLED_APPS

and I've updated settings with LAZYSIGNUP_USER_MODEL = 'core.SLUser' to use my User custom module.

SLUser custom model is extending AbstractUser.

When I've done the python manage.py migrate command

I've got this error:

Running migrations for core:
- Nothing to migrate.
 - Loading initial data for core.
Installed 0 object(s) from 0 fixture(s)
Running migrations for authtoken:
- Nothing to migrate.
 - Loading initial data for authtoken.
Installed 0 object(s) from 0 fixture(s)
Running migrations for djcelery:
- Nothing to migrate.
 - Loading initial data for djcelery.
Installed 0 object(s) from 0 fixture(s)
Running migrations for lazysignup:
 - Migrating forwards to 0002_auto__add_field_lazyuser_created.
 > lazysignup:0001_initial
FATAL ERROR - The following SQL query failed: ALTER TABLE "lazysignup_lazyuser" ADD CONSTRAINT "user_id_refs_id_cab6fc22" FOREIGN KEY ("user_id") REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED;
The error was: relation "auth_user" does not exist

Error in migration: lazysignup:0001_initial
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 111, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 220, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 254, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 329, in migrate_many
    result = self.migrate(migration, database)
  File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration, database)
  File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 114, in run
    return self.run_migration(migration, database)
  File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 85, in run_migration
    south.db.db.execute_deferred_sql()
  File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 318, in execute_deferred_sql
    self.execute(sql)
  File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 282, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "auth_user" does not exist

What should I do?

Thanks for help.

Cheers,

                 Ema.
danfairs commented 10 years ago

Hm, that does look like a bug. You might be able to work around it temporarily by disabling your custom user, running the migrations, re-enabling it and generating the required migrations to move the foreign keys around.

StErMi commented 10 years ago

Could it be possible that this bug is because I'm using django > 1.5 with a custom user model? I saw other issue like this online Il 15/ago/2014 12:56 "Dan Fairs" notifications@github.com ha scritto:

Hm, that does look like a bug. You might be able to work around it temporarily by disabling your custom user, running the migrations, re-enabling it and generating the required migrations to move the foreign keys around.

— Reply to this email directly or view it on GitHub https://github.com/danfairs/django-lazysignup/issues/41#issuecomment-52294935 .

danfairs commented 10 years ago

Yes, that's almost certainly related. lazysignup predates the custom user support in Django, and I've never really had time to work support into lazysignup properly.