4

I updated my django 1.4 application with user profiles to use 1.5 Custom User Model.

#core/models.py

from django.contrib.auth.models import User, UserManager, BaseUserManager, AbstractUser

class MyUserManager(BaseUserManager):
    pass

class MyUser(AbstractUser):
    phone = models.CharField(blank = True, max_length = 18)
    completed_step = models.IntegerField(default = 0)
    objects = MyUserManager()

I wrote schema migrations for south and all data was imported successfully.

Otherwise, I have a problem with auth_group and auth_permision. Django can't generate any additional tables, but when I want to get permissions or groups I have this SQL with JOIN to additional table:

 SELECT ...
      FROM "core_myuser"
      WHERE "core_myuser"."id" = 61 (8ms) Found 1 matching rows
 SELECT ...
      FROM "core_myuser"
      WHERE "core_myuser"."id" = 363 (1ms) Found 1 matching rows
 SELECT ...
      FROM "auth_group"
      INNER JOIN "core_myuser_groups" ON ("auth_group"."id" = "core_myuser_groups"."group_id")
      WHERE "core_myuser_groups"."myuser_id" = 363

With Internal Server Error

http://cl.ly/image/0W1G3F2S3f3X

1 Answers1

0

You have not created appropriate table in the database. Make tables before switching user model:

python manage.py syncdb
#or if you're use south
python manage.py schemamigration core --initial
python manage.py migrate core

Then write custom migration script for you user data, or you'll lose it.

Look this manual and this documentation, it'll help you to understend what should be done.

Yevgeniy Shchemelev
  • 3,601
  • 2
  • 32
  • 39