from django.db.models.signals import post_save, post_delete
from .models import RecurringEvent, RecurringEventExclusion


def update_event(sender, instance, raw=False, **kwargs):
    if not raw:
        instance.event.save()


post_save.connect(update_event, sender=RecurringEvent)
post_save.connect(update_event, sender=RecurringEventExclusion)
post_delete.connect(update_event, sender=RecurringEvent)
post_delete.connect(update_event, sender=RecurringEventExclusion)

from django.db.models.signals import post_save, post_delete
from .models import Event, RecurringEvent, RecurringEventExclusion


def update_event(sender, instance, raw=False, **kwargs):
    if not raw:
        try:
            instance.event.save()
        except Event.DoesNotExist:
            pass


post_save.connect(update_event, sender=RecurringEvent)
post_save.connect(update_event, sender=RecurringEventExclusion)
post_delete.connect(update_event, sender=RecurringEvent)
post_delete.connect(update_event, sender=RecurringEventExclusion)

Fix for when the event gets deleted before the recurring event or recurring event exclusion
Fix for when the event gets deleted before the recurring event or recurring event exclusion

  from django.db.models.signals import post_save, post_delete
- from .models import RecurringEvent, RecurringEventExclusion
+ from .models import Event, RecurringEvent, RecurringEventExclusion
  
  
  def update_event(sender, instance, raw=False, **kwargs):
      if not raw:
+         try:
-         instance.event.save()
+             instance.event.save()
+         except Event.DoesNotExist:
+             pass
  
  
  post_save.connect(update_event, sender=RecurringEvent)
  post_save.connect(update_event, sender=RecurringEventExclusion)
  post_delete.connect(update_event, sender=RecurringEvent)
  post_delete.connect(update_event, sender=RecurringEventExclusion)
  
Fix for when the event gets deleted before the recurring event or recurring event exclusion
## Code Before:
from django.db.models.signals import post_save, post_delete
from .models import RecurringEvent, RecurringEventExclusion


def update_event(sender, instance, raw=False, **kwargs):
    if not raw:
        instance.event.save()


post_save.connect(update_event, sender=RecurringEvent)
post_save.connect(update_event, sender=RecurringEventExclusion)
post_delete.connect(update_event, sender=RecurringEvent)
post_delete.connect(update_event, sender=RecurringEventExclusion)

## Instruction:
Fix for when the event gets deleted before the recurring event or recurring event exclusion
## Code After:
from django.db.models.signals import post_save, post_delete
from .models import Event, RecurringEvent, RecurringEventExclusion


def update_event(sender, instance, raw=False, **kwargs):
    if not raw:
        try:
            instance.event.save()
        except Event.DoesNotExist:
            pass


post_save.connect(update_event, sender=RecurringEvent)
post_save.connect(update_event, sender=RecurringEventExclusion)
post_delete.connect(update_event, sender=RecurringEvent)
post_delete.connect(update_event, sender=RecurringEventExclusion)
