@classmethod
def _requires_ckan_version(cls, min_version, max_version=None):
    """Raise :py:exc:`~ckan.plugins.toolkit.CkanVersionException` if the
        CKAN version is not greater than or equal to ``min_version`` and
        less then or equal to ``max_version``.

        If no ``max_version`` is given, just check whether the CKAN version is
        greater than or equal to ``min_version``.

        Plugins can call this function if they require a certain CKAN version,
        other versions of CKAN will crash if a user tries to use the plugin
        with them.

        :param min_version: the minimum acceptable CKAN version,
            eg. ``'2.1'``
        :type min_version: string

        :param max_version: the maximum acceptable CKAN version,
            eg. ``'2.3'``
        :type max_version: string

        """
    from ckan.exceptions import CkanVersionException
    if not cls._check_ckan_version(min_version=min_version, max_version=
        max_version):
        if not max_version:
            error = 'Requires ckan version %s or higher' % min_version
        else:
            error = 'Requires ckan version between {0} and {1}'.format(
                min_version, max_version)
        raise CkanVersionException(error)
