Skip to content

Deprecated spirit_user.User

Esteban Castro Borsani edited this page Jan 31, 2018 · 15 revisions

The spirit_user.User is removed in Spirit v0.5. This are the previous steps to upgrading from v0.4 to v0.5 in case you have AUTH_USER_MODEL = 'spirit_user.User' from back in the day (Spirit v0.2).

Make sure you have a backup of your database and follow these steps:

  • Run python manage.py makemigrations there should be no new migrations for user, if there are, are you also upgrading the Django version? if so, DO NOT do that now, do it later.
  • Create your own custom user app. Should contain a models.py file (see required user model below) and an empty migrations package.
  • Add AUTH_USER_MODEL = 'my_custom_user.User' in settings.py.
  • Add the custom app to INSTALLED_APPS, i.e: INSTALLED_APPS += ['my_custom_user'] (notice the plus/concat sign)
  • Run python manage.py makemigrations, there should be new migrations in the custom user app.
  • Run python manage.py migrate --fake-initial my_custom_user where my_custom_user is the name of the custom user app.
  • Run python manage.py migrate --fake spirit_user 0007_auto_20161114_1536 this will skip a exception that prevents data loss (ie: for those who are not following these steps here).
  • Run python manage.py migrate --fake spirit_user 0008_auto_20161114_1707 this will skip the migration that removes the user model table.
  • Follow the upgrade steps.

Required user model:

# my_custom_user/models.py

from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import AbstractUser

class User(AbstractUser):

    class Meta(AbstractUser.Meta):
        swappable = 'AUTH_USER_MODEL'
        ordering = ['-date_joined', '-pk']
        verbose_name = _('user')
        verbose_name_plural = _('users')
        db_table = 'spirit_user_user'
Clone this wiki locally