Django Rest Framework Temperature Data Querying

90 views
Skip to first unread message

Burak Özdemir

unread,
Jan 2, 2017, 5:16:24 PM1/2/17
to Django REST framework
My sensor measures the temperature value every 5 seconds and records it to the database. I want to see the highest and lowest temperature of every recorded day via API. It should be like that(for instance, values are not correct): 

The modal:
class SensorModel(models.Model):
    measurementTime
= models.DateTimeField()
    ldr
= models.IntegerField()
    temperature
= models.IntegerField()
    humidity
= models.IntegerField()

class Meta:
    ordering
= ['measurementTime']

def __unicode__(self):
   
return str(self.id)


Database:

Current API: 

Thanks in advance.


Marco Silva

unread,
Jan 3, 2017, 5:06:03 AM1/3/17
to Django REST framework
What exactly do you need help in?

Burak Özdemir

unread,
Jan 3, 2017, 6:09:15 AM1/3/17
to Django REST framework
I want to create an API endpoint for daily temperatures.(highest and lowest tempereture of a day).

3 Ocak 2017 Salı 13:06:03 UTC+3 tarihinde Marco Silva yazdı:

gordon

unread,
Jan 3, 2017, 5:43:46 PM1/3/17
to django-res...@googlegroups.com
List_route or detail route decorators sounds like what you are looking for http://www.django-rest-framework.org/api-guide/viewsets/#marking-extra-actions-for-routing

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marco Silva

unread,
Jan 4, 2017, 6:43:55 AM1/4/17
to django-res...@googlegroups.com

Actually, I  think he wants a custom serializer that has one of 2 get arguments(start and end date) and then generates the desired json with fields using the django aggregate methods


To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/bhGJR4tndMc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.

Burak Özdemir

unread,
Jan 4, 2017, 6:59:17 AM1/4/17
to Django REST framework
There are lots of temperature data for one day. For instance, there are nearly 5000 records for 03 January. I want to get highest and lowest of these records for one specific day.

4 Ocak 2017 Çarşamba 14:43:55 UTC+3 tarihinde Marco Silva yazdı:
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/bhGJR4tndMc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-framework+unsub...@googlegroups.com.

Marco Silva

unread,
Jan 4, 2017, 7:02:35 AM1/4/17
to Django REST framework

On a custom serializer field, (eg SerializerMethodField) use the django aggregate functions for max and min https://docs.djangoproject.com/en/1.10/topics/db/aggregation/


To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/bhGJR4tndMc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/bhGJR4tndMc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages