(self)
return cleaned_data
Applies security measures to recipe editing.
Applies security measures to recipe editing.
Applies security measures to recipe editing .
def clean(self):
        """
        Applies security measures to recipe editing.
        """
        cleaned_data = super(RecipeForm, self).clean()

        # Anonymous users cannot edit.
        if self.user.is_anonymous:
            raise forms.ValidationError('You need to be logged in.')

        # Check to see if the recipe is writable.
        self.validate_writable()

        # Fill with default values.
        for field in self.Meta.fields:
            if cleaned_data.get(field) is None:
                cleaned_data[field] = getattr(self.instance, field)

        return cleaned_data
def clean ( self ) : cleaned_data = super ( RecipeForm , self ) . clean ( ) # Anonymous users cannot edit. if self . user . is_anonymous : raise forms . ValidationError ( 'You need to be logged in.' ) # Check to see if the recipe is writable. self . validate_writable ( ) # Fill with default values. for field in self . Meta . fields : if cleaned_data . get ( field ) is None : cleaned_data [ field ] = getattr ( self . instance , field ) return cleaned_data