Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom user models and South
    primarykey
    data
    text
    <p>I'm trying to use a custom user model in the most basic way, extending <code>AbstractUser</code> as described at <a href="https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-django-s-default-user">Extending Django’s default User</a>. But, I'm not sure how to properly make this work with South. I'm running into a problem when doing an initial schema migration with Here's what happening:</p> <ul> <li><p>I've got my extended user class, <code>Player</code>, in my class <code>tournaments</code>, which is enabled in <code>settings.INSTALLED_APPS</code>. </p></li> <li><p>To perform an initial <code>syncdb</code>, the <code>tournaments</code> app must be enabled. Otherwise I get this error:</p> <pre><code>$ ./manage.py syncdb CommandError: One or more models did not validate: auth.user: Model has been swapped out for 'tournaments.Player' which has not been installed or is abstract. admin.logentry: 'user' has a relation with model tournaments.Player, which has either not been installed or is abstract. </code></pre></li> <li><p>So, I enable the <code>tournaments</code> app that has my <code>Player</code> (custom user) model. But then, upon the initial migration:</p> <pre><code>$ ./manage.py schemamigration tournaments --initial ... $ ./manage.py migrate tournaments Running migrations for tournaments: - Migrating forwards to 0001_initial. &gt; tournaments:0001_initial FATAL ERROR - The following SQL query failed: CREATE TABLE "tournaments_player" ("id" serial NOT NULL PRIMARY KEY, "password" varchar(128) NOT NULL, "last_login" timestamp with time zone NOT NULL, "is_superuser" boolean NOT NULL, "username" varchar(30) NOT NULL UNIQUE, "first_name" varchar(30) NOT NULL, "last_name" varchar(30) NOT NULL, "email" varchar(75) NOT NULL, "is_staff" boolean NOT NULL, "is_active" boolean NOT NULL, "date_joined" timestamp with time zone NOT NULL, "bio" text NOT NULL); The error was: relation "tournaments_player" already exists Error in migration: tournaments:0001_initial DatabaseError: relation "tournaments_player" already exists </code></pre></li> </ul> <p>If I skip the <code>syncdb</code>, I get this error, because <code>syncdb</code> is necessary to bootstrap South:</p> <pre><code>$ ./manage.py migrate tournaments DatabaseError: relation "south_migrationhistory" does not exist LINE 1: ...gration", "south_migrationhistory"."applied" FROM "south_mig... </code></pre> <p>So, it appears that I've got a chicken/egg situation here: I can't <code>syncdb</code> without my user model. But, if I <code>syncdb</code> with my user model, I can't perform an initial migration! </p> <p>What is the best way to get around this? I've got some ideas, like running the initial <code>syncdb</code> without <code>django.contrib.auth</code> and <code>django.contrib.admin</code> enabled, or running the initial <code>syncdb</code> without <code>south</code> enabled and then converting the app. Both options seem hackey and strange. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload