diff --git a/home/models/pages.py b/home/models/pages.py index 49c66c0..4257e5f 100644 --- a/home/models/pages.py +++ b/home/models/pages.py @@ -330,12 +330,15 @@ class EventPage(Page): now = timezone.now() if not self.recurrence_enabled: # if recurrence is not enabled, ensure there's at least one occurrence for the specified start/end + # and delete any other occurrences that don't match the current start/end if self.occurrences.exists(): occurrence = self.occurrences.first() if occurrence.start != self.start or occurrence.end != self.end: occurrence.start = self.start occurrence.end = self.end occurrence.save(update_fields=["start", "end"]) + + self.occurrences.exclude(id=occurrence.id).delete() else: EventOccurrence.objects.create( event=self, start=self.start, end=self.end