school = models.ForeignKey(School, on_delete=models.CASCADE, related_name='atlethe_school_group')
email = models.EmailField(blank=True, null=True)
notes = models.TextField(blank=True, null=True)
backend/api/migrations/0011_athlete.py
After creating the model, I ran the makemigrations command and the migration for the Athlete model was created.
backend/api/serializers/AthleteSerializer.py
Created a Model serializer for the Athlete model. Included all the fields.
Add a validation method for date_of_birth to check the date is not in the future.
backend/api/views/AthleteView.py
Created a basic Model View set for Athlete.
backend/api/urls.py
Added a router to generate the endpoints for Athlete.
backend/api/fixtures/setup_data.json
Added data for 6 Athlete objects.
I applied the migration with migrate command, then loaded the fixture data with loaddata command.
Swagger
The endpoints are accessible through Swagger:
I tried each of the new endpoints successfully. I was able to create, delete, patch and get an athlete.
When posting and patching, I got the expected error for entering invalid data.
This PR addresses issue #21
Implementation
backend/api/migrations/0011_athlete.py After creating the model, I ran the
makemigrations
command and the migration for the Athlete model was created.backend/api/serializers/AthleteSerializer.py Created a Model serializer for the Athlete model. Included all the fields. Add a validation method for date_of_birth to check the date is not in the future.
backend/api/views/AthleteView.py Created a basic Model View set for Athlete.
backend/api/urls.py Added a router to generate the endpoints for Athlete.
backend/api/fixtures/setup_data.json
Added data for 6 Athlete objects.
I applied the migration with
migrate
command, then loaded the fixture data withloaddata
command.Swagger
The endpoints are accessible through Swagger:
I tried each of the new endpoints successfully. I was able to create, delete, patch and get an athlete. When posting and patching, I got the expected error for entering invalid data.