Fix program times having no item in clean (#5635)

This error occurs only when adding a program-time form in the frontend and not saving it, but removing it again and then saving the item.
This commit is contained in:
Richard Schreiber
2025-11-18 14:59:31 +01:00
committed by GitHub
parent ed43bf327e
commit 313f4f326b

View File

@@ -2311,7 +2311,7 @@ class ItemProgramTime(models.Model):
end = models.DateTimeField(verbose_name=_("End"))
def clean(self):
if self.item.event.has_subevents:
if hasattr(self, 'item') and self.item and self.item.event.has_subevents:
raise ValidationError(_("You cannot use program times on an event series."))
self.clean_start_end(start=self.start, end=self.end)
super().clean()