Search code examples
djangodjango-registrationdjango-1.5

django-registration with Django 1.5


I've been trying to get django-registration to work with Django 1.5 Configurable User Models.

I've seen some previous SO threads related to the error I'm having, but the solution to them doesn't seem to be working for me.

The error I get is:

"registration.registrationprofile: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL"

I understand this is related to the fact that django-registration doesn't seem to know about me using a custom user model, but I was under the impression this was fixed in the newer version.

The django-registration version I'm using says:

(0, 9, 0, 'beta', 1)

I don't think it has anything to do with my code as I've encountered this error on two projects using different code bases.

Just to cover the bases, though:

settings.py

AUTH_USER_MODEL = 'reg.MyUser'

and a cannibalized version of the Django 1.5 Customizable User Model guide I've been following:

models.py

class MyUserManager(BaseUserManager):
    def create_user(self, email):

        user = self.model(
            email=MyUserManager.normalize_email(email),
        )

        user.save(using=self._db)
        return user

class MyUser(AbstractBaseUser):
    email = models.EmailField(max_length=254, unique=True, db_index=True)

    is_active = models.BooleanField(default=True)
    is_admin = models.BooleanField(default=False)

    objects = MyUserManager()

    USERNAME_FIELD = 'email'


    def get_full_name(self):
        return self.email

    def get_short_name(self):
        return self.email

    def __unicode__(self):
        return self.email

    def has_perm(self, perm, obj=None):
        return True

    def has_module_perms(self, app_label):
        return True

    @property
    def is_staff(self):
        return self.is_admin

Any help is appreciated in figuring out what's going wrong.

Jace


Solution

  • It doesn't seem to be updated to work with configurable user models yet based on the following lines from here

    from django.contrib.auth.models import User
    
    class RegistrationProfile(models.Model):
        user = models.ForeignKey(User, unique=True, verbose_name=_('user'))