Works by watching for the pre_save signal for those classes
and if it sees that the isdefault flag being set to true it
goes through all the other records and sets isdefault to null.
"""Clear default if needed
"""
if instance.isdefault:
- for c in ClusterStation.objects.all():
+ for c in ClusterStation.objects.filter(isdefault=True).all():
if c.id != instance.id:
c.isdefault = False
c.save()
"""Clear default if needed
"""
if instance.isdefault:
- for s in Sequencer.objects.all():
+ for s in Sequencer.objects.filter(isdefault=True).all():
if s.id != instance.id:
s.isdefault = False
s.save()