Почему код создает пустой объект в Django Rest Framework

По какой-то причине, когда я отправляю данные с фронтенда, бэкенд создает пустые объекты.

models.py

class Workout(models.Model):
    GOALS_CHOICES = (
        ('None', 'None'),
        ('Abs', 'Abs'), ('Arms', 'Arms'),
        ('Cardio', 'Cardio'), ('Core', 'Core'),
        ('Endurance', 'Endurance'),
        ('Flexibility', 'Flexibility'), ('Full Body', 'Full Body'),
        ('Legs', 'Legs'), ('Lower Body', 'Lower Body'),
        ('Power', 'Power'),
        ('Shoulders', 'Shoulders'), ('Sport Conditioning', 'Sport Conditioning'), ('Stability', 'Stability'), ('Strength', 'Strength'),
        ('Toning', 'Toning'),
        ('Upper Body', 'Upper Body'),
        ('Weight Loss', 'Weight Loss')
    )

    exercises = models.ManyToManyField(Exercise, through='Targets')
    name = models.CharField(max_length=200, blank=True)
    profile = models.ForeignKey(Profile, on_delete=SET_NULL,null=True, blank=True)
    description = models.TextField(max_length=3000, blank=True)
    goals = models.CharField(max_length=25, choices=GOALS_CHOICES, default='None')
    workout_time = models.CharField(max_length=200, blank=True)
    difficulty = models.CharField(max_length=10,blank=True)    
    status = models.CharField(max_length=15, default='Created')
    created = models.DateField(auto_now_add=timezone.now())
    assigned = models.DateField(blank=True, null=True)
    completed = models.DateField(blank=True, null=True)
    time = models.CharField(max_length=100, blank=True, null=True)
    rating = models.IntegerField(default=0, blank=True, null=True,
                                    validators=[MaxValueValidator(5),
                                    MinValueValidator(0)])
    overall_notes = models.TextField(max_length=3000, blank=True)
    favorited = models.CharField(max_length=1, null=True, blank=True)

    def __str__(self):
        return self.name

serializers.py

class WorkoutSerializer(serializers.ModelSerializer):
    """Serializer for workout objects"""
    class Meta:
        model = Workout
        fields = ['id', 'name', 'description', 'goals', 'workout_time', 'difficulty', 'status', 'created', 'assigned', 'completed', 'rating', 'overall_notes', 'favorited']
        read_only_fields = ('id',)

views.py

class WorkoutListCreateAPIView(generics.ListCreateAPIView):
    queryset = Workout.objects.all().order_by('assigned').order_by('completed')
    serializer_class = WorkoutSerializer

Почему мой код создает пустые объекты. Я тестировал через Postman, и смог создать указанный объект. Предложения?

Вернуться на верх