瀏覽代碼

[5.0.x] Refs #26029 -- Improved get_storage_class() deprecation warning with stacklevel=2.

Addition of the `stacklevel` argument shows the source of the
deprecated call, making updating the client code simpler.
Carlton Gibson 1 年之前
父節點
當前提交
fa6e6f3113
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      django/core/files/storage/__init__.py

+ 5 - 1
django/core/files/storage/__init__.py

@@ -29,7 +29,11 @@ GET_STORAGE_CLASS_DEPRECATED_MSG = (
 
 
 def get_storage_class(import_path=None):
-    warnings.warn(GET_STORAGE_CLASS_DEPRECATED_MSG, RemovedInDjango51Warning)
+    warnings.warn(
+        GET_STORAGE_CLASS_DEPRECATED_MSG,
+        RemovedInDjango51Warning,
+        stacklevel=2,
+    )
     return import_string(import_path or settings.DEFAULT_FILE_STORAGE)