• Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard
CSEstack

What do you want to Learn Today?

  • Programming
    • Tutorial- C/C++
    • Tutorial- Django
    • Tutorial- Git
    • Tutorial- HTML & CSS
    • Tutorial- Java
    • Tutorial- MySQL
    • Tutorial- Python
    • Competitive Coding Challenges
  • CSE Subject
    • (CD) Compiler Design
    • (CN) Computer Network
    • (COA) Computer Organization & Architecture
    • (DBMS) Database Management System
    • (DS) Data Structure
    • (OS) Operating System
    • (ToA) Theory of Automata
    • (WT) Web Technology
  • Interview Questions
    • Interview Questions- Company Wise
    • Interview Questions- Coding Round
    • Interview Questions- Python
    • Interview Questions- REST API
    • Interview Questions- Web Scraping
    • Interview Questions- HR Round
    • Aptitude Preparation Guide
  • GATE 2022
  • Linux
  • Trend
    • Full Stack Development
    • Artificial Intelligence (AI)
    • BigData
    • Cloud Computing
    • Machine Learning (ML)
  • Write for Us
    • Submit Article
    • Submit Source Code or Program
    • Share Your Interview Experience
  • Tools
    • IDE
    • CV Builder
    • Other Tools …
  • Jobs

12 Django Default User Model Fields You Should Know

Aniruddha Chaudhari/1599/0
Django

Django has the default user model which comes with some of the useful fields. You should embrace using these fields in your project.

Django Default User Model Fields

Here is the list of default Django user fields.

#User Model FieldData TypeDescription
1_stateModelStateIt is used to preserve the state of the user.
2idNumberUnique ID for each user.
3password stringEncrypted password for the user.
4last_logindatetimeDate and time when user logged in last time.
5is_superuserboolTrue if the user is superuser, otherwise false.
6usernamestringUnique username for the user.
7first_name stringFirst name of the user.
8last_name stringLast name of the user.
9emailemailEmail ID of the user.
10is_staff boolSet true if the user is a staff member, else false.
11is_active boolIs profile active.
12date_joined datetime Date and time when the user joined the first time. It is usually when the user signs up or creates a user account the first time.

How to read all the user model fields?

As this is the default model, you don’t need to define it anywhere. You can simply use it.

Reading model data in Django is pretty easy.

Import User model from the set of Django authentication models.

from django.contrib.auth.models import User

users = User.objects.filter()

Just to see or to debug you can also print all the user fields for a particular user. Let’s say print all the fields for the first user.

from django.contrib.auth.models import User

users = User.objects.filter()

print(users[0].__dict__)

These user-defined fields are also used for user authentication in the Django registrations.

You can also check all the user’s data on the Django admin site.

Django default user model fields

Extending Django User Model

There are some more fields you might need for your user profile in your project. Let’s say, you also want to save the mobile number of the user. Likewise, there can be many fields you want to add.

For this, you can extend the Django Default User Model Fields. It is like creating a new model (says profile) and linking with the default User model. The relationship between the two models will be OneToOne-mapping. We will see that in the next tutorial.

Any doubt? Let’s discuss this in the comment section below.

Python Interview Questions eBook

Django
Aniruddha Chaudhari
I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.

Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

Leave a Reply Cancel reply

Prerequisite for Django

Learn Python Basics

Django Tutorials

Why Django?

Django- Create Your First Project

Django- Adding CSS/Static Files

Django- Use/Load Static Files

Django- Create Form

Django- Create Input-Tags

Django- Display Message on Form Submit

Django- MultipleChoiceField in Form

Django- Read Model Data (order_by)

Django- Read First/Last Queryset Object

Django- Update Model Field

Django- Signals

Django- Create TextField in Form

Django- Add Model to Admin Site

Django- Customize Admin Site

Django- Understanding Model User

Django- Registration/Signup Form

Django- Form Layout with Widget-Tweaks

Django- OneToOneField in Model

Django- Foreign Key & Reverse Lookup

Django- Custom Template Filters

Django- Interactive Shell

Django- Social Login

Django- Deploy and Host [FREE] 🔥

© 2022 – CSEstack.org. All Rights Reserved.

  • Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard