latest timestamp with one of those backends.
On Sep 30, 9:47 am, Dmitry Kuznetsov <dkuznet...@gmail.com> wrote:
> Something like this?
>
> backends = [backend1,backend2,backend3]
> latest_status = Status.objects.filter(backend__in=backends).latest()
>
> Regards,
> Dmitry
>
> On Sep 29, 7:36 pm, Colin <cwoo...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi Users,
>
> > So I have a DB that has a list of backends and there properties and I
> > have a table that gets updated with if it is able to access and the
> > status. It is only updated when it is reported down or, if it was
> > reported down and is currenly back up.
>
> > What i want to do is make a queryset that will get only the latest
> > status for a list of backends.
>
> > #models.py
>
> > class Backend(models.Model):
> > src_host = models.CharField(max_length=255)
> > ip = models.CharField(max_length=45)
> > port = models.CharField(max_length=8)
> > endpoint_name = models.CharField(max_length=255)
> > service_prop_name = models.CharField(max_length=255)
> > endpoint_url = models.CharField(max_length=255)
>
> > class Status(models.Model):
> > backend = models.ForeignKey(Backend)
> > timestamp = models.DateTimeField()
> > status = models.CharField(max_length=255)
>
> > class Meta():
> > get_latest_by = 'timestamp'
>
> > What I would like to do is get the latest status reported for the last
> > ten minutes. Without having to loop through a list querysets and
> > performing the .latest() function on it.
>
> > Is this possible?
>
> > Thanks,
>
> > Colin
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment