I'm trying to simply post data using this django serializer but I'm constantly receiving the error Class ProductSerializer missing "Meta.model" attribute. Do you know if I'm missing something:
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model : Product
fields : ['title','image','likes']
This is my model:
class Product(models.Model):
title = models.CharField(max_length=200)
image = models.CharField(max_length=200)
likes = models.PositiveIntegerField(default=0)
You are using colon instead of an equal to sign. It should be model = Product :
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ('title','image','likes')