-
-
Notifications
You must be signed in to change notification settings - Fork 332
Deprecated spirit_user.User
Esteban C Borsani edited this page Jun 17, 2020
·
15 revisions
The spirit_user.User
is removed in Spirit v0.5. If you have AUTH_USER_MODEL = 'spirit_user.User'
defined from way back in the day (Spirit v0.2), you must follow this guide before upgrading from v0.4 to v0.5.
Make sure you have a backup of your database and follow these steps:
- Do not upgrade to Spirit 0.5. You may do that later on. Make sure you are on latest v0.4.x
- Run
python manage.py makemigrations
, there should be no new migrations. If there are, are you upgrading Django? don't do that yet, you may do it later on. - Create your own custom user app. It should contain a
models.py
file (see required user model below) and an emptymigrations
package. - Add
AUTH_USER_MODEL = 'my_custom_user.User'
to settings.py. - Add the custom app to
INSTALLED_APPS
, i.e:INSTALLED_APPS += ['my_custom_user']
(notice the plus sign/concat symbol) - 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
wheremy_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 an exception that prevents data loss (it's there 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 deprecated 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'