2

I'm working on an existing Django project in Django 1.4. I want to upgrade to Django 1.5 for implementing a custom user model. I have to ensure that my existing information is not deleted from the database(Postgres 9.1).

This post explains the steps to be done for data migration using South but only for AbstractUser. I have to use AbstractBaseUser. Is there any way?

My existing model is like :

class Individual(models.Model):
  user = models.ForeignKey(User, unique=True, blank=True, null=True)
  parent = models.ForeignKey('self', unique=True, blank=True, null=True)
  ....(some many to many and foreign key)

I want to change it to something like this.

class User(AbstractBaseUser, Individual, PermissionsMixin):
  email = models.EmailFeild(max_length=50, unique=True)
  is_admin = models.BooleanField(default=False)
  username = models.CharField(max_length=50,unique=True)
  USERNAME_FIELD = 'username'
  REQUIRED_FIELDS = ['email']

The individual class will contain all previous fields except the user. How can I go about doing this?

4

1 回答 1

0

文档如何从内置用户模型迁移到自定义用户模型线程有一些解决方法讨论。

于 2019-03-05T20:44:46.810 回答