[Answer]-Django auth ldap with custom user model

1👍

This is the part of django_auth_ldap‘s models.py –

class TestProfile(models.Model):
    """
    A user profile model for use by unit tests. This has nothing to do with the
    authentication backend itself.
    """
    user = models.OneToOneField('auth.User')  # <-- here is the trouble
    is_special = models.BooleanField(default=False)
    populated = models.BooleanField(default=False)

You cannot fix it unless you fix this part of the code and do as said in Django documentation

Instead of referring to User directly, you should reference the user
model using django.contrib.auth.get_user_model(). This method will
return the currently active User model – the custom User model if one
is specified, or User otherwise.

And I wont recommend modifying the 3rd party packages yourself. If you can, go suggest the change to the developer, or send them a pull request. Once it’s accepted, update the package.

Leave a comment