A REST API built with Python, Django, Django Rest Framework (DRF).
This project provides an appointment service where registered doctors and patients can schedule appointments. It provides endpoints for basic CRUD operations on each entity (i.e. Doctor, Patient, Appointment) and some filtering options based on query parameters.
/myproj/myapi/
- models.py - Defines the models.
- validators.py - Defines custom validators for models.
- serializers.py - Serializes the models.
- views.py - Defines the HTTP methods and behaviors for a request.
- urls.py - Maps endpoint URLs to approriate views.
/myproj/myproj/
- urls.py - Includes all endpoints defined in
/myproj/myapi/urls.py. - settings.py - Defines the settings for the project (i.e. enables
myapiandrest_framework).
$ pip install django
$ pip install djangorestframework
$ pip install django-filter
$ cd myproj
$ python3 manage.py runserver
$ python3 manage.py makemigrations
$ python3 manage.py migrate
id: int (primary key)first_name: stringlast_name: string
id: int (primary key)first_name: stringlast_name: string
id: int (primary key)doctor: Doctor (foreign key)patient: Patient (foreign key)date: datetime.datetime: datetime.timekind: string ('NP' - "New Patient", 'FU' - "Follow-up")
- Displays hyperlinks to main endpoints:
GET ''
Interacts with the Doctor model
- Show all doctors:
GET /doctors/ - Add new doctor:
POST /doctors/ - Show a doctor:
GET /doctors/<doctor.id>/ - Update a doctor:
PUT /doctors/<doctor.id>/ - Delete a doctor:
DELETE /doctors/<doctor.id>/
Interacts with the Patient model
- Show all patients:
GET /patients/ - Add new patient:
POST /patients/ - Show a patient:
GET /patients/<patient.id>/ - Update a patient:
PUT /patients/<patient.id>/ - Delete a patient:
DELETE /patients/<patient.id>/
Interacts with the Appointment model
- Show all appointments:
GET /appointments/ - Schedule a new appointment:
POST /appointments/ - Cancel an appointment:
DELETE /appointments/ - Show an appointment:
GET /appointments/<appointment.id>/ - Update an appointment:
PUT /appointments/<appointment.id>/ - Delete an appointment:
DELETE /appointments/<appointment.id>/
?id={}&doctor={}&patient={}&date={}&time={}&kind={}
- params:
appointment.id,doctor.id,patient.id,appointment.date,appointment.time,appointment.kind