I am working with a laptop rental program, and I was wondering if there is a better way to do this lookup. This works fine, but it seems like it could be better.
from django.db import models class Laptop(models.Model): def laptops_out_on(date): 'get a list of laptops out on a given day' result = Laptop.objects.none() for x in Rental.objects.filter(checkout__lte=date, checkin__gte=date): result = result | x.laptops.all() return result laptops_out_on = staticmethod(laptops_out_on) class Rental(models.Model): checkout = models.DateField(blank=True) checkin = models.DateField(blank=True) laptops = models.ManyToManyField(Laptop, blank=True) Thanks, Collin --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---