diff --git a/django/utils/six.py b/django/utils/six.py index 52627592b750..481a03974aa4 100644 --- a/django/utils/six.py +++ b/django/utils/six.py @@ -186,6 +186,15 @@ def find_module(self, fullname, path=None): return self return None + # For python 3.12 + def find_spec(self, fullname, path, target=None): + from importlib.util import spec_from_loader + loader = self.find_module(fullname, path) + if loader is None: + return None + + return spec_from_loader(fullname, loader) + def __get_module(self, fullname): try: return self.known_modules[fullname]