def clean(self):
        """Validates the form to make sure that there is at least one default plan"""

        cleaned_data = super(PlanForm, self).clean()
        is_default = cleaned_data.get("is_default")
        engine = cleaned_data.get("engine")
        if not engine:
            msg = _("Please select a Engyne Type")
            log.warning(u"%s" % msg)
            raise forms.ValidationError(msg)
        if not is_default:
            if self.instance.id:
                plans = models.Plan.objects.filter(
                    is_default=True, engine=engine).exclude(id=self.instance.id)
            else:
                plans = models.Plan.objects.filter(
                    is_default=True, engine=engine)
            if not plans:
                msg = _("At least one plan must be default")
                log.warning(u"%s" % msg)
                raise forms.ValidationError(msg)

        return cleaned_data
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/physical/forms/plan_admin.py/PlanForm.clean/original