Junior — Senior
Loading data from external JSON‑API into course and level models
livecode
Task condition
It is necessary to process a JSON array received from an external API and record the information into the Course and Level models, considering their relationships.
from rest_framework import serializers
from courses.models import Course
class CourseSerializer(serializers.ModelSerializer):
class Meta:
model = Course
fields = '__all__'
[
{
"Code": "01.03.02",
"Specialty": "Applied Mathematics and Informatics",
"Profile": "Simulation Modeling and Data Analysis, 2021",
"TrainingLevel": "Bachelor's"
},
{
"Code": "01.03.02",
"Specialty": "Applied Mathematics and Informatics",
"Profile": "Simulation Modeling and Data Analysis, 2022",
"TrainingLevel": "Bachelor's"
},
{
"Code": "01.03.02",
"Specialty": "Applied Mathematics and Informatics",
"Profile": "Simulation Modeling and Data Analysis, 2023",
"TrainingLevel": "Bachelor's"
}
]