Hi, just a couple of follow-up questions as having trouble following precisely.
Can you re-state the exact queries you’re looking for? - Are you looking to check if there are tools of a given type available at a given time? - And whether a tool of a given type can be booked in a given time window? - When you said you wanted to “fold” 2 bookings into the same time window - intuitively at first glance a booking app would want to do the opposite, ie. find empty time windows - could you elaborate on these booking use cases? Is this for a single customer who wants to book multiple tools at a time? - Sharing the Tool and Booking models would be useful. This may be too basic, but for time queries if you’re not already aware there are the keyword lookups gt, gte (greater than, greater than or equal to) and lt, lte, for example: now = timezone.now() active_bookings_for_tool_type = Booking.objects.filter(tool__resource=2, start_time__lte=now, finish_time__gte=now) and timedelta from the datetime module is useful for handling time intervals. Also there are some open source django booking apps out there which look pretty good, for example django-booking: https://github.com/bitlabstudio/django-booking - could be worth looking into? On Tuesday, January 10, 2017 at 3:05:33 PM UTC, MikeKJ wrote: > > May be another way of doing this? > > 5 tools @ 9 hours = 45 hours maximum possible utilisation > 1 tool = 9 hours maximum possible utilisation > > each tool is a list > pa = [] (tool1) > pb = [] (tool2) etc > > max = 9 > need to know the count of objects > loop all the booking objects > use the max count as the index > test if all booked hours exceeds max if not then list pa is complete > else > add together object hours to not exceed max and make each list pa, pb etc > ending up with > pa = [(object, object, object)] > pb = [(object, object, object, object)] etc > then unpack the tuples in the template with if statements to position as > to time and duration > > Would that work better? > What code would achieve it? > Appreciate any help here > > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/141e1af8-86c2-498e-b6ce-0a39a4fc3ac2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.