I have this model:
class Entry(models.Model):
time = models.DateTimeField()
no2 = models.FloatField()
co = models.FloatField()
humidity = models.FloatField()
temperature = models.FloatField()
and rest view:
class DataList(ListAPIView):
serializer_class = EntrySerializer
def get_queryset(self):
return Entry.objects.all()
I want to have next options to filter data via get parameters (like /entries?period=week):
- Get last entry
- Get average values for each of last 7 days
- Get average values for each of last 12 months.
How to implement it via django rest framework?