def validate(self, data=None, only=None, exclude=None):
        """
        Validate the data for all fields and return whether the validation was successful.
        This method also retains the validated data in ``self.data`` so that it can be accessed later.

        This is usually the method you want to call after creating the validator instance.

        :param data: Dictionary of data to validate.
        :param only: List or tuple of fields to validate.
        :param exclude: List or tuple of fields to exclude from validation.
        :return: True if validation was successful. Otherwise False.
        """
        only = only or []
        exclude = exclude or []
        data = data or {}
        self.errors = {}
        self.data = {}

        # Validate individual fields.
        for name, field in self._meta.fields.items():
            if name in exclude or (only and name not in only):
                continue
            try:
                field.validate(name, data)
            except ValidationError as err:
                self.add_error(name, err)
                continue
            self.data[name] = field.value

        # Clean individual fields.
        if not self.errors:
            self.clean_fields(self.data)

        # Then finally clean the whole data dict.
        if not self.errors:
            try:
                self.data = self.clean(self.data)
            except ValidationError as err:
                self.add_error('__base__', err)

        return (not self.errors)
def validate ( self , data = None , only = None , exclude = None ) : only = only or [ ] exclude = exclude or [ ] data = data or { } self . errors = { } self . data = { } for name , field in self . _meta . fields . items ( ) : if name in exclude or ( only and name not in only ) : continue try : field . validate ( name , data ) except ValidationError as err : self . add_error ( name , err ) continue self . data [ name ] = field . value if not self . errors : self . clean_fields ( self . data ) if not self . errors : try : self . data = self . clean ( self . data ) except ValidationError as err : self . add_error ( '__base__' , err ) return ( not self . errors )
Validate the data for all fields and return whether the validation was successful.
        This method also retains the validated data in ``self.data`` so that it can be accessed later.

        This is usually the method you want to call after creating the validator instance.

        :param data: Dictionary of data to validate.
        :param only: List or tuple of fields to validate.
        :param exclude: List or tuple of fields to exclude from validation.
        :return: True if validation was successful. Otherwise False.