I try to write data migration code for custom user type but when I try to apply migration I get this:
TypeError: 'Permission' instance expected, got <Permission: my_app | Some Text | Can add some_model>
Looks weird to me. Isn't that a Permission instance? Here is my custom user model:
class Employee(AbstractUser):
middle_name = models.CharField(max_length=60, null=True, blank=True)
And here is a piece of code in migration which raises this error (I guess so):
for user in User.objects.all():
employee = orm.Employee.objects.create(
id=user.id,
username=user.username,
first_name=user.first_name,
last_name=user.last_name,
password=user.password,
email=user.email,
is_active=user.is_active,
is_superuser=user.is_superuser,
last_login=user.last_login,
date_joined=user.date_joined,
)
for perm in user.user_permissions.all():
employee.user_permissions.add(perm)