0

I want to get all users information to set up user profiles including superuser, but somehow my code doesn't get superuser data . Please have a look

from django.contrib.auth.models import User
from django.db import models

class UserProfile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
Knight
  • 55
  • 2
  • 7

1 Answers1

0

as per the docs, 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. So use User = get_user_model() or settings.AUTH_USER_MODEL if you a custom user

bmons
  • 3,352
  • 2
  • 10
  • 18