Migrating existing auth.User data to new Django 1.5 custom user model?

前端 未结 5 1179
余生分开走
余生分开走 2020-11-30 18:59

I\'d prefer not to destroy all the users on my site. But I want to take advantage of Django 1.5\'s custom pluggable user model. Here\'s my new user model:

         


        
5条回答
  •  温柔的废话
    2020-11-30 19:55

    My incredibly lazy way of doing this:

    1. Create a new model (User), extending AbstractUser. Within new model, in it's Meta, override db_table and set to 'auth_user'.

    2. Create an initial migration using South.

    3. Migrate, but fake the migration, using --fake when running migrate.

    4. Add new fields, create migration, run it normally.

    This is beyond lazy, but works. You now have a 1.5 compliant User model, which just uses the old table of users. You also have a proper migration history.

    You can fix this later on with manual migrations to rename the table.

提交回复
热议问题