No matter what I do i cannot post to /collections
it keeps on saying that the aggregate field products_count is required.
has anyone else been able to POST to /collections?
I get the error on POST:
{
“products_count”: [
“This field is required.”
]
}
Did you make products_count a read-only field in your serializer?
Here’s what I have:
class CollectionSerializer(serializers.ModelSerializer):
class Meta:
model = Collection
fields = ['id', 'title', 'products_count']
products_count = serializers.IntegerField(read_only=True)
3 Likes
no I didnt,
that was the issue, thanks
1 Like
I used like to avoid this error
products_count = serializers.IntegerField(required = False)
1 Like