Now that Django supports the DateRangeField, is there a 'Pythonic' way to 
prevent records from having overlapping date ranges?

# Hypothetical use case
One hypothetical use case would be a booking system, where you don't want 
people to book the same resource at the same time.

# Hypothetical example code
<!-- language: lang-py -->

    class Booking(models.model):
        # The resource to be reserved
        resource = models.ForeignKey('Resource')
        # When to reserve the resource
        date_range = models.DateRangeField()

        class Meta:
            unique_together = ('resource', 'date_range',)

This might have the effect of adding an exclusion constraint on the underlying 
table:
https://www.postgresql.org/docs/9.3/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/38774F1F-C132-4F55-A72F-A4449C0A14D9%40amble.fi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to