Vitalii Ponomar
Vitalii Ponomar

Reputation: 10936

Django authentication with custom model UserProfile (not builtin User)

For my needs builtin model User is not enough... So I have my own model UserProfile and I want make authentication on site through this model (UserProfile does not inherit from User model and not related to it at all).

But builtin authentication uses model User.

So I want to understand how can I change that, so authentication use my model UserProfile with all auth features???

Thanks in advance!!!

Upvotes: 0

Views: 288

Answers (1)

juankysmith
juankysmith

Reputation: 12448

You have to create your own Authentication Backend to tell Django to create a UserProfile instead a User.

In this examples, the user model is extended so you will have to adapt it to your own requirements:

Example 1

Example 2

Upvotes: 2

Related Questions