yeah thats exactly what i want to do
this is my model.py
class TypeOfUser(models.TextChoices):
PATIENT = 'patient', 'Patient'
DOCTOR = 'doctor', 'Doctor'
RECEPTION = 'reception', 'Reception'
TEMPORARY = 'temporary', 'Temporary'
class AllowdToTakeAppointement(models.TextChoices):
YES = ('yes', 'Yes')
NO = ('no', 'No')
class User(AbstractUser):
type_of_user = models.CharField(max_length=200, choices=TypeOfUser.choices, default=TypeOfUser.PATIENT)
allowd_to_take_appointement = models.CharField(max_length=20, choices=AllowdToTakeAppointement.choices, default=AllowdToTakeAppointement.YES)
# profile information in user models
BLOOD_GROUPS = [
('O-', 'O-'),
('O+', 'O+'),
('A-', 'A-'),
('A+', 'A+'),
('B-', 'B-'),
('B+', 'B+'),
('AB-', 'AB-'),
('AB+', 'AB+'),
]
GENDER_CHOICES = (('M', 'Male'), ('F', 'Female'),)
date_of_birth = models.DateField(blank=True, null=True)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
phone_number = PhoneNumberField(blank=True)
blood_group = models.CharField(choices=BLOOD_GROUPS, max_length=3, blank=True)
address = models.CharField(max_length=500, blank=True)
def is_doctor(self):
return self.type_of_user == TypeOfUser.DOCTOR
class Appointment(models.Model):
user_ho_add = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_ho_add_appointment')
patient = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, related_name='patient_app')
doctor = models.ForeignKey(User, on_delete=models.CASCADE, related_name='doctor_app')
date = models.DateField(null=False, blank=False, default=timezone.now)
start_time = models.TimeField(null=True, blank=True, default=timezone.now)
end_time = models.TimeField(null=True, blank=True, default=timezone.now)
In the user model I add the type of user (doctor, patient…), and if he can add an appointment or not
And the benefit of this idea is that I can create another model for medical profile that the patient can see or use