create appointment for register and non register user

I’m stuck in the attempt to create an appointment application with Django to register (as a patient) and non registered user (doctor makes appointment for non register patient)

  • for register user it’s easy he login and book an appointement using appointment form

  • for non register my idea is to create a new user with a type = temporary with usereditform and after creating this user we can add an appointment for his (This allows us not to write down this patient information every time he wants to book an appointment -his information will be registered as a temporary user-)

my question is
is this idea a good one or there is a better way to do it
if it is how can i create this new tomporary user without password or email, and how can i make it in the view.py ( after creating the new user the next page of appointment book the appointment for the new user )

Thanks in advance for any suggestions.

If a person gets an appointment as a “non-registered user”, and then comes back again later, is it going to be the same user?

If the “non-registered user” later decides to register, should they remain the “same user”?

If the answer to both these questions is “yes”, then I wouldn’t make a distinction about the type of user. I would just allow the doctor (or doctor’s staff) to create a user account.
I might track whether the user is “user registered” or “doctor registered” to allow for the user at a later date to “take ownership” of their account, but that’s probably as far as I would go in that direction.

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