[Django]-Saving a Serializer in Django

2👍

Your current create method instantiates a new RSS object but doesn’t save it. Try this:

def create(self, validated_data):
    rss = RSS.objects.create(**validated_data)
    rss.created_at = datetime.now()
    ...
    return rss.save()

More info: Django rest framework: override create() in ModelSerializer passing an extra parameter

http://www.django-rest-framework.org/api-guide/serializers/#saving-instances

If your object instances correspond to Django models you’ll also want to ensure that these methods save the object to the database.

Leave a comment