diff --git a/aleksis/core/models.py b/aleksis/core/models.py index b632d4353d3557b424b22e522eb7e4b587b03fda..f1b5ca2cb1a04e1bf8b36ad8aa500044070ab1ad 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -1707,10 +1707,16 @@ class CalendarEvent(CalendarEventMixin, ExtensiblePolymorphicModel, RecurrenceMo name="datetime_end_or_date_end", ), models.CheckConstraint( - check=Q(datetime_end__gte=F("datetime_start")), name="datetime_start_before_end" + check=Q(datetime_end__gte=F("datetime_start")) + | Q(datetime_start__isnull=True) + | Q(datetime_end__isnull=True), + name="datetime_start_before_end", ), models.CheckConstraint( - check=Q(date_end__gte=F("date_start")), name="date_start_before_end" + check=Q(date_end__gte=F("date_start")) + | Q(date_start__isnull=True) + | Q(date_end__isnull=True), + name="date_start_before_end", ), models.CheckConstraint( check=~(Q(datetime_start__isnull=False, timezone="") & ~Q(recurrences="")),