database/study_models.py
def save(self, *args, **kwargs):
        """ Ensure there is a study device settings attached to this study. """
        # First we just save. This code has vacillated between throwing a validation error and not
        # during study creation.  Our current fix is to save, then test whether a device settings
        # object exists.  If not, create it.
        try:
            self.forest_param
        except ObjectDoesNotExist:
            self.forest_param = ForestParam.objects.get(default=True)
        super().save(*args, **kwargs)
        try:
            self.device_settings
        except ObjectDoesNotExist:
            settings = DeviceSettings(study=self)
            self.device_settings = settings
            settings.save()
            # update the study object to have a device settings object (possibly unnecessary?).
            super().save(*args, **kwargs)
 Ensure there is a study device settings attached to this study. 
Ensure there is a study device settings attached to this study.
Ensure there is a study device settings attached to this study .
def save(self, *args, **kwargs):
        try:
            self.forest_param
        except ObjectDoesNotExist:
            self.forest_param = ForestParam.objects.get(default=True)
        super().save(*args, **kwargs)
        try:
            self.device_settings
        except ObjectDoesNotExist:
            settings = DeviceSettings(study=self)
            self.device_settings = settings
            settings.save()
            super().save(*args, **kwargs)
def save ( self , * args , ** kwargs ) : try : self . forest_param except ObjectDoesNotExist : self . forest_param = ForestParam . objects . get ( default = True ) super ( ) . save ( * args , ** kwargs ) try : self . device_settings except ObjectDoesNotExist : settings = DeviceSettings ( study = self ) self . device_settings = settings settings . save ( ) super ( ) . save ( * args , ** kwargs )
Ensure there is a study device settings attached to this study.
Ensure there is a study device settings attached to this study .
""" Ensure there is a study device settings attached to this study. """ # First we just save. This code has vacillated between throwing a validation error and not # during study creation.  Our current fix is to save, then test whether a device settings # object exists.  If not, create it. # update the study object to have a device settings object (possibly unnecessary?).
self