utils.module_loading.import_string()

import_string(dotted_path) [source]

Imports a dotted module path and returns the attribute/class designated by the last name in the path. Raises ImportError if the import failed. For example:

1
2
from django.utils.module_loading import import_string
ValidationError = import_string('django.core.exceptions.ValidationError')

is equivalent to:

1
from django.core.exceptions import ValidationError
doc_Django
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.