2

What are the attributes that are defined in the Django AbstractUser model?

I have extended the model:

from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): pass 

Do I have to create my own fields for username, first name, last name, etc? Or are they already defined?

2 Answers 2

3

Here you can find these fields are already defined. https://github.com/django/django/blob/master/django/contrib/auth/models.py#L288

However if you want user class without these fields look for AbstractBaseUser class https://github.com/django/django/blob/master/django/contrib/auth/base_user.py#L47

Sign up to request clarification or add additional context in comments.

Comments

1

Yes those fields (username, email, first_name, last_name, is_staff, is_active, date_joined) are already defined for the AbstractUser. You can view the fields in the django admin. Check the source code here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.