def get_fieldsets(self, fieldsets=None):
        """
        This method returns a generator which yields fieldset instances.

        The method uses the optional fieldsets argument to generate fieldsets for.
        If no fieldsets argument is passed, the class property ``fieldsets`` is used.

        When generating the fieldsets, the method ensures that at least one fielset
        will be the primary fieldset which is responsible for rendering the non field
        errors and hidden fields.

        :param fieldsets: Alternative set of fieldset kwargs. If passed this set is
                          prevered of the ``fieldsets`` property of the form.
        :return: generator which yields fieldset instances.
        """
        fieldsets = fieldsets or self.fieldsets

        if not fieldsets:
            raise StopIteration

        # Search for primary marker in at least one of the fieldset kwargs.
        has_primary = any(fieldset.get('primary') for fieldset in fieldsets)

        for fieldset_kwargs in fieldsets:
            fieldset_kwargs = copy.deepcopy(fieldset_kwargs)
            fieldset_kwargs['form'] = self

            if not has_primary:
                fieldset_kwargs['primary'] = True
                has_primary = True

            yield self.get_fieldset(**fieldset_kwargs)
This method returns a generator which yields fieldset instances.

        The method uses the optional fieldsets argument to generate fieldsets for.
        If no fieldsets argument is passed, the class property ``fieldsets`` is used.

        When generating the fieldsets, the method ensures that at least one fielset
        will be the primary fieldset which is responsible for rendering the non field
        errors and hidden fields.

        :param fieldsets: Alternative set of fieldset kwargs. If passed this set is
                          prevered of the ``fieldsets`` property of the form.
        :return: generator which yields fieldset instances.