I parse data from a restful API call using django-rest-framework ModelSerializer. Here is the code:
url = "API URL HERE"
r = requests.get(url)
json = r.json()
serializer = myModelSerializer(data=json, many=True)
if serializer.is_valid():
serializer.save()
Here is the modelSerializer:
class myModelSerializer(serializers.ModelSerializer):
class Meta:
model = MyModel
MYModel:
class MyModel(models.Model):
City = models.NullBooleanField(default=False, null=True)
Status = models.CharField(max_length=100, null=True)
stateName = models.CharField(max_length=50)
marketingName = models.TextField(null=True)
county = models.CharField(max_length=200, null=True)
My problem is I need to find out what field value changed from the last time I called the restful api and updated data. OR If there is any new records. How do I achieve this?