My Model is like below.
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
('O', 'Other'),
)
USER_TYPE = (
('S', 'Super Admin'),
('A', 'Admin'),
('P', 'Patient'),
('D', 'Doctor'),
('U', 'User'),
)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
date_of_birth = models.DateField()
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
user_type = models.CharField(max_length=1, choices=USER_TYPE)
email = models.EmailField(unique=True)
phone = models.CharField(max_length=15, blank=True, null=True)
address = models.TextField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
def __str__(self):
return f"{self.first_name} {self.last_name}"
I am getting message like below.
It is impossible to add a non-nullable field 'password' to user without specifying a default. This is because the database needs something to populate existing rows.
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Quit and manually define a default value in models.py.