diff options
| author | zhengkangyang <1872483761@qq.com> | 2026-06-06 16:17:24 +0800 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-06-10 10:17:34 -0400 |
| commit | f970a98e464320c09dde8d45009eadfb4d038a57 (patch) | |
| tree | 23211de1605cff20d774a93ccdbbb5ff4c928c2d /docs/ref | |
| parent | 17a56cd6e600cfb02972657e8958b5ee2e0f936e (diff) | |
Fixed #37142 -- Moved django_file_prefixes() to django.utils.warnings.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/utils.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 1c42784d13..0f38105713 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -1187,3 +1187,31 @@ For a complete discussion on the usage of the following see the Turns a Django template into something that is understood by ``xgettext``. It does so by translating the Django translation tags into standard ``gettext`` function invocations. + +``django.utils.warnings`` +========================= + +.. module:: django.utils.warnings + :synopsis: Helpers for issuing warnings. + +.. function:: django_file_prefixes() + + .. versionadded:: 6.2 + + Returns a tuple of file path prefixes for the Django package directory. + This is used as the ``skip_file_prefixes`` argument to + :func:`warnings.warn` so that warnings are attributed to the *caller* + (your project or third-party library) rather than to Django internals. + + The result is cached after the first call. + + Usage example:: + + import warnings + from django.utils.warnings import django_file_prefixes + + warnings.warn( + "Your custom warning message.", + category=RuntimeWarning, + skip_file_prefixes=django_file_prefixes(), + ) |
