diff --git a/jazzmin/__init__.py b/jazzmin/__init__.py index 60bb152b..b05aa9db 100644 --- a/jazzmin/__init__.py +++ b/jazzmin/__init__.py @@ -1,6 +1,19 @@ import django +import sys + +# We automatically grab the version of `django-jazzmin` from the package manager instead of +# hard coding it. The method for determining the version changed since PY3.8. N.B. For +# development versions of `django-jazzmin`, the version will be 0.0.0 (see pyproject.toml) as it's +# not technically installed. +if sys.version_info >= (3, 8): + from importlib.metadata import version as package_version + + version = package_version("django-jazzmin") +else: + import pkg_resources + + version = pkg_resources.get_distribution("django-jazzmin").version -version = "2.6.1" if django.VERSION < (3, 2): default_app_config = "jazzmin.apps.JazzminConfig" diff --git a/pyproject.toml b/pyproject.toml index 9dde9809..f9b8f3c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -146,3 +146,10 @@ commands = [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" + + +[[tool.mypy.overrides]] +module = [ + "pkg_resources.*", +] +ignore_missing_imports = true