diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8939dd3db..27bbcb763 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,3 +31,9 @@ repos: hooks: - id: codespell exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js + +- repo: https://github.com/asottile/pyupgrade + rev: v3.19.1 + hooks: + - id: pyupgrade + args: ["--py39-plus", "--keep-percent-format"] diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index c387af972..0eee3c99f 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -451,7 +451,7 @@ If your views have related customizations that are needed frequently, you can create a base `AutoSchema` subclass for your project that takes additional `__init__()` kwargs to save subclassing `AutoSchema` for each view. -[cite]: https://blog.heroku.com/archives/2014/1/8/json_schema_for_heroku_platform_api +[cite]: https://www.heroku.com/blog/json_schema_for_heroku_platform_api/ [openapi]: https://github.com/OAI/OpenAPI-Specification [openapi-specification-extensions]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#specification-extensions [openapi-operation]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#operationObject diff --git a/docs/community/funding.md b/docs/community/funding.md index 10e09bf71..7bca4bae4 100644 --- a/docs/community/funding.md +++ b/docs/community/funding.md @@ -114,7 +114,7 @@ If you use REST framework commercially we strongly encourage you to invest in it Signing up for a paid plan will: * Directly contribute to faster releases, more features, and higher quality software. -* Allow more time to be invested in documentation, issue triage, and community support. +* Allow more time to be invested in keeping the package up to date. * Safeguard the future development of REST framework. REST framework continues to be open-source and permissively licensed, but we firmly believe it is in the commercial best-interest for users of the project to invest in its ongoing development. @@ -134,18 +134,6 @@ REST framework continues to be open-source and permissively licensed, but we fir --- -## What future funding will enable - -* Realtime API support, using WebSockets. This will consist of documentation and support for using REST framework together with Django Channels, plus integrating WebSocket support into the client libraries. -* Better authentication defaults, possibly bringing JWT & CORS support into the core package. -* Securing the community & operations manager position long-term. -* Opening up and securing a part-time position to focus on ticket triage and resolution. -* Paying for development time on building API client libraries in a range of programming languages. These would be integrated directly into the upcoming API documentation. - -Sign up for a paid plan today, and help ensure that REST framework becomes a sustainable, full-time funded project. - ---- - ## What our sponsors and users say > As a developer, Django REST framework feels like an obvious and natural extension to all the great things that make up Django and it's community. Getting started is easy while providing simple abstractions which makes it flexible and customizable. Contributing and supporting Django REST framework helps ensure its future and one way or another it also helps Django, and the Python ecosystem. @@ -165,6 +153,8 @@ DRF is one of the core reasons why Django is top choice among web frameworks tod > > — Andrew Conti, Django REST framework user +Sign up for a paid plan today, and help ensure that REST framework becomes a sustainable, full-time funded project. + --- ## Individual plan diff --git a/docs/community/third-party-packages.md b/docs/community/third-party-packages.md index 9d25665ad..d213cac3d 100644 --- a/docs/community/third-party-packages.md +++ b/docs/community/third-party-packages.md @@ -160,6 +160,7 @@ To submit new content, [create a pull request][drf-create-pr]. ### Customization +* [drf-restwind][drf-restwind] - a modern re-imagining of the Django REST Framework utilizes TailwindCSS and DaisyUI to provide flexible and customizable UI solutions with minimal coding effort. * [drf-redesign][drf-redesign] - A project that gives a fresh look to the browse-able API using Bootstrap 5. * [drf-material][drf-material] - A project that gives a sleek and elegant look to the browsable API using Material Design. @@ -254,6 +255,7 @@ To submit new content, [create a pull request][drf-create-pr]. [django-requestlogs]: https://github.com/Raekkeri/django-requestlogs [drf-standardized-errors]: https://github.com/ghazi-git/drf-standardized-errors [drf-api-action]: https://github.com/Ori-Roza/drf-api-action +[drf-restwind]: https://github.com/youzarsiph/drf-restwind [drf-redesign]: https://github.com/youzarsiph/drf-redesign [drf-material]: https://github.com/youzarsiph/drf-material -[django-pyoidc] : https://github.com/makinacorpus/django_pyoidc +[django-pyoidc]: https://github.com/makinacorpus/django_pyoidc diff --git a/docs/img/drf-m-api-root.png b/docs/img/drf-m-api-root.png new file mode 100644 index 000000000..02a756287 Binary files /dev/null and b/docs/img/drf-m-api-root.png differ diff --git a/docs/img/drf-m-detail-view.png b/docs/img/drf-m-detail-view.png new file mode 100644 index 000000000..33e3515d8 Binary files /dev/null and b/docs/img/drf-m-detail-view.png differ diff --git a/docs/img/drf-m-list-view.png b/docs/img/drf-m-list-view.png new file mode 100644 index 000000000..a7771957d Binary files /dev/null and b/docs/img/drf-m-list-view.png differ diff --git a/docs/img/drf-r-api-root.png b/docs/img/drf-r-api-root.png new file mode 100644 index 000000000..5704cc350 Binary files /dev/null and b/docs/img/drf-r-api-root.png differ diff --git a/docs/img/drf-r-detail-view.png b/docs/img/drf-r-detail-view.png new file mode 100644 index 000000000..2959c7201 Binary files /dev/null and b/docs/img/drf-r-detail-view.png differ diff --git a/docs/img/drf-r-list-view.png b/docs/img/drf-r-list-view.png new file mode 100644 index 000000000..1930b5dc0 Binary files /dev/null and b/docs/img/drf-r-list-view.png differ diff --git a/docs/img/drf-rw-api-root.png b/docs/img/drf-rw-api-root.png new file mode 100644 index 000000000..15b498b9b Binary files /dev/null and b/docs/img/drf-rw-api-root.png differ diff --git a/docs/img/drf-rw-detail-view.png b/docs/img/drf-rw-detail-view.png new file mode 100644 index 000000000..6e821acda Binary files /dev/null and b/docs/img/drf-rw-detail-view.png differ diff --git a/docs/img/drf-rw-list-view.png b/docs/img/drf-rw-list-view.png new file mode 100644 index 000000000..625b5c7c9 Binary files /dev/null and b/docs/img/drf-rw-list-view.png differ diff --git a/docs/img/rfm.png b/docs/img/rfm.png deleted file mode 100644 index 7c82621af..000000000 Binary files a/docs/img/rfm.png and /dev/null differ diff --git a/docs/img/rfr.png b/docs/img/rfr.png deleted file mode 100644 index 1854511d0..000000000 Binary files a/docs/img/rfr.png and /dev/null differ diff --git a/docs/topics/browsable-api.md b/docs/topics/browsable-api.md index fe35be8b3..8cf530b7a 100644 --- a/docs/topics/browsable-api.md +++ b/docs/topics/browsable-api.md @@ -81,22 +81,43 @@ For more specific CSS tweaks than simply overriding the default bootstrap theme ### Third party packages for customization -You can use a third party package for customization, rather than doing it by yourself. Here is 2 packages for customizing the API: +You can use a third party package for customization, rather than doing it by yourself. Here is 3 packages for customizing the API: -* [rest-framework-redesign][rest-framework-redesign] - A package for customizing the API using Bootstrap 5. Modern and sleek design, it comes with the support for dark mode. -* [rest-framework-material][rest-framework-material] - Material design for Django REST Framework. +* [drf-restwind][drf-restwind] - a modern re-imagining of the Django REST Framework utilizes TailwindCSS and DaisyUI to provide flexible and customizable UI solutions with minimal coding effort. +* [drf-redesign][drf-redesign] - A package for customizing the API using Bootstrap 5. Modern and sleek design, it comes with the support for dark mode. +* [drf-material][drf-material] - Material design for Django REST Framework. --- -![Django REST Framework Redesign][rfr] +![API Root][drf-rw-api-root] -*Screenshot of the rest-framework-redesign* +![List View][drf-rw-list-view] + +![Detail View][drf-rw-detail-view] + +*Screenshots of the drf-restwind* --- -![Django REST Framework Material][rfm] +--- -*Screenshot of the rest-framework-material* +![API Root][drf-r-api-root] + +![List View][drf-r-list-view] + +![Detail View][drf-r-detail-view] + +*Screenshot of the drf-redesign* + +--- + +![API Root][drf-m-api-root] + +![List View][drf-m-api-root] + +![Detail View][drf-m-api-root] + +*Screenshot of the drf-material* --- @@ -197,7 +218,15 @@ There are [a variety of packages for autocomplete widgets][autocomplete-packages [bcomponentsnav]: https://getbootstrap.com/2.3.2/components.html#navbar [autocomplete-packages]: https://www.djangopackages.com/grids/g/auto-complete/ [django-autocomplete-light]: https://github.com/yourlabs/django-autocomplete-light -[rest-framework-redesign]: https://github.com/youzarsiph/rest-framework-redesign -[rest-framework-material]: https://github.com/youzarsiph/rest-framework-material -[rfr]: ../img/rfr.png -[rfm]: ../img/rfm.png +[drf-restwind]: https://github.com/youzarsiph/drf-restwind +[drf-rw-api-root]: ../img/drf-rw-api-root.png +[drf-rw-list-view]: ../img/drf-rw-list-view.png +[drf-rw-detail-view]: ../img/drf-rw-detail-view.png +[drf-redesign]: https://github.com/youzarsiph/drf-redesign +[drf-r-api-root]: ../img/drf-r-api-root.png +[drf-r-list-view]: ../img/drf-r-list-view.png +[drf-r-detail-view]: ../img/drf-r-detail-view.png +[drf-material]: https://github.com/youzarsiph/drf-material +[drf-m-api-root]: ../img/drf-m-api-root.png +[drf-m-list-view]: ../img/drf-m-list-view.png +[drf-m-detail-view]: ../img/drf-m-detail-view.png diff --git a/rest_framework/authtoken/management/commands/drf_create_token.py b/rest_framework/authtoken/management/commands/drf_create_token.py index 3d6539244..3f4521fe4 100644 --- a/rest_framework/authtoken/management/commands/drf_create_token.py +++ b/rest_framework/authtoken/management/commands/drf_create_token.py @@ -42,4 +42,4 @@ class Command(BaseCommand): username) ) self.stdout.write( - 'Generated token {} for user {}'.format(token.key, username)) + f'Generated token {token.key} for user {username}') diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 6989edc0a..89c0a714c 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -111,7 +111,7 @@ def get_attribute(instance, attrs): # If we raised an Attribute or KeyError here it'd get treated # as an omitted field in `Field.get_attribute()`. Instead we # raise a ValueError to ensure the exception is not masked. - raise ValueError('Exception raised in callable attribute "{}"; original exception was: {}'.format(attr, exc)) + raise ValueError(f'Exception raised in callable attribute "{attr}"; original exception was: {exc}') return instance @@ -1103,7 +1103,7 @@ class DecimalField(Field): if self.localize: return localize_input(quantized) - return '{:f}'.format(quantized) + return f'{quantized:f}' def quantize(self, value): """ @@ -1861,7 +1861,7 @@ class SerializerMethodField(Field): def bind(self, field_name, parent): # The method name defaults to `get_{field_name}`. if self.method_name is None: - self.method_name = 'get_{field_name}'.format(field_name=field_name) + self.method_name = f'get_{field_name}' super().bind(field_name, parent) diff --git a/rest_framework/locale/ar/LC_MESSAGES/django.mo b/rest_framework/locale/ar/LC_MESSAGES/django.mo index f793d7c73..a3c7c5ca2 100644 Binary files a/rest_framework/locale/ar/LC_MESSAGES/django.mo and b/rest_framework/locale/ar/LC_MESSAGES/django.mo differ diff --git a/rest_framework/locale/ar/LC_MESSAGES/django.po b/rest_framework/locale/ar/LC_MESSAGES/django.po index 58f72ec17..be261d8dd 100644 --- a/rest_framework/locale/ar/LC_MESSAGES/django.po +++ b/rest_framework/locale/ar/LC_MESSAGES/django.po @@ -8,6 +8,7 @@ # Bashar Al-Abdulhadi, 2016-2017 # Eyad Toma , 2015,2017 # zak zak , 2020 +# Salman Saeed Albukhaitan , 2024 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" @@ -24,19 +25,19 @@ msgstr "" #: authentication.py:70 msgid "Invalid basic header. No credentials provided." -msgstr "رأس أساسي غير صالح, لم تقدم اي بيانات." +msgstr "ترويسة أساسية غير صالحة. لم تقدم أي بيانات تفويض." #: authentication.py:73 msgid "Invalid basic header. Credentials string should not contain spaces." -msgstr "رأس أساسي غير صالح, سلسلة البيانات لا يجب أن تحتوي على أي أحرف مسافات" +msgstr "ترويسة أساسية غير صالحة. يجب أن لا تحتوي سلسلة بيانات التفويض على مسافات." #: authentication.py:83 msgid "Invalid basic header. Credentials not correctly base64 encoded." -msgstr "رأس أساسي غير صالح, البيانات ليست مرمّزة بصحة على أساس64." +msgstr "ترويسة أساسية غير صالحة. بيانات التفويض لم تُشفر بشكل صحيح بنظام أساس64." #: authentication.py:101 msgid "Invalid username/password." -msgstr "اسم المستخدم/كلمة السر غير صحيحين." +msgstr "اسم المستخدم/كلمة المرور غير صحيحة." #: authentication.py:104 authentication.py:206 msgid "User inactive or deleted." @@ -93,7 +94,7 @@ msgstr "كلمة المرور" #: authtoken/serializers.py:35 msgid "Unable to log in with provided credentials." -msgstr "تعذر تسجيل الدخول بالبيانات التي ادخلتها." +msgstr "تعذر تسجيل الدخول بالبيانات المدخلة." #: authtoken/serializers.py:38 msgid "Must include \"username\" and \"password\"." @@ -101,11 +102,11 @@ msgstr "يجب أن تتضمن \"اسم المستخدم\" و \"كلمة الم #: exceptions.py:102 msgid "A server error occurred." -msgstr "حدث خطأ في المخدم." +msgstr "حدث خطأ في الخادم." #: exceptions.py:142 msgid "Invalid input." -msgstr "" +msgstr "مدخل غير صالح." #: exceptions.py:161 msgid "Malformed request." @@ -130,11 +131,11 @@ msgstr "غير موجود." #: exceptions.py:191 #, python-brace-format msgid "Method \"{method}\" not allowed." -msgstr "الطريقة \"{method}\" غير مسموح بها." +msgstr "طريقة \"{method}\" غير مسموح بها." #: exceptions.py:202 msgid "Could not satisfy the request Accept header." -msgstr "لم نتمكن من تلبية الرٱس Accept في الطلب." +msgstr "تعذر تلبية ترويسة Accept في الطلب." #: exceptions.py:212 #, python-brace-format @@ -143,17 +144,17 @@ msgstr "الوسيط \"{media_type}\" الموجود في الطلب غير مع #: exceptions.py:223 msgid "Request was throttled." -msgstr "تم تقييد الطلب." +msgstr "تم حد الطلب." #: exceptions.py:224 #, python-brace-format msgid "Expected available in {wait} second." -msgstr "" +msgstr "متوقع التوفر خلال {wait} ثانية." #: exceptions.py:225 #, python-brace-format msgid "Expected available in {wait} seconds." -msgstr "" +msgstr "متوقع التوفر خلال {wait} ثواني." #: fields.py:316 relations.py:245 relations.py:279 validators.py:90 #: validators.py:183 @@ -166,11 +167,11 @@ msgstr "لا يمكن لهذا الحقل ان يكون فارغاً null." #: fields.py:701 msgid "Must be a valid boolean." -msgstr "" +msgstr "يجب أن يكون قيمة منطقية صالحة." #: fields.py:766 msgid "Not a valid string." -msgstr "" +msgstr "ليس نصاً صالحاً." #: fields.py:767 msgid "This field may not be blank." @@ -179,16 +180,16 @@ msgstr "لا يمكن لهذا الحقل ان يكون فارغاً." #: fields.py:768 fields.py:1881 #, python-brace-format msgid "Ensure this field has no more than {max_length} characters." -msgstr "تأكد ان الحقل لا يزيد عن {max_length} محرف." +msgstr "تأكد ان عدد الحروف في هذا الحقل لا تتجاوز {max_length}." #: fields.py:769 #, python-brace-format msgid "Ensure this field has at least {min_length} characters." -msgstr "تأكد ان الحقل {min_length} محرف على الاقل." +msgstr "تأكد ان عدد الحروف في هذا الحقل لا يقل عن {min_length}." #: fields.py:816 msgid "Enter a valid email address." -msgstr "عليك ان تدخل بريد إلكتروني صالح." +msgstr "يرجى إدخال عنوان بريد إلكتروني صحيح." #: fields.py:827 msgid "This value does not match the required pattern." @@ -204,7 +205,7 @@ msgstr "أدخل \"slug\" صالح يحتوي على حروف، أرقام، ش msgid "" "Enter a valid \"slug\" consisting of Unicode letters, numbers, underscores, " "or hyphens." -msgstr "" +msgstr "أدخل \"slug\" صالح يحتوي على حروف يونيكود، أرقام، شُرط سفلية أو واصلات." #: fields.py:854 msgid "Enter a valid URL." @@ -212,7 +213,7 @@ msgstr "الرجاء إدخال رابط إلكتروني صالح." #: fields.py:867 msgid "Must be a valid UUID." -msgstr "" +msgstr "يجب أن يكون معرف UUID صالح." #: fields.py:903 msgid "Enter a valid IPv4 or IPv6 address." @@ -225,16 +226,16 @@ msgstr "الرجاء إدخال رقم صحيح صالح." #: fields.py:932 fields.py:969 fields.py:1005 fields.py:1366 #, python-brace-format msgid "Ensure this value is less than or equal to {max_value}." -msgstr "تأكد ان القيمة أقل أو تساوي {max_value}." +msgstr "تأكد ان القيمة أقل من أو تساوي {max_value}." #: fields.py:933 fields.py:970 fields.py:1006 fields.py:1367 #, python-brace-format msgid "Ensure this value is greater than or equal to {min_value}." -msgstr "تأكد ان القيمة أكبر أو تساوي {min_value}." +msgstr "تأكد ان القيمة أكبر من أو تساوي {min_value}." #: fields.py:934 fields.py:971 fields.py:1010 msgid "String value too large." -msgstr "السلسلة اطول من القيمة المسموح بها." +msgstr "النص طويل جداً." #: fields.py:968 fields.py:1004 msgid "A valid number is required." @@ -249,7 +250,7 @@ msgstr "تأكد ان القيمة لا تحوي أكثر من {max_digits} رق #, python-brace-format msgid "" "Ensure that there are no more than {max_decimal_places} decimal places." -msgstr "تأكد انه لا يوجد اكثر من {max_decimal_places} منازل عشرية." +msgstr "تأكد انه لا يوجد اكثر من {max_decimal_places} أرقام عشرية." #: fields.py:1009 #, python-brace-format @@ -261,7 +262,7 @@ msgstr "تأكد انه لا يوجد اكثر من {max_whole_digits} أرقا #: fields.py:1148 #, python-brace-format msgid "Datetime has wrong format. Use one of these formats instead: {format}." -msgstr "صيغة التاريخ و الوقت غير صحيحة. عليك أن تستخدم واحدة من هذه الصيغ التالية: {format}." +msgstr "صيغة التاريخ و الوقت غير صحيحة. عليك أن تستخدم احد الصيغ التالية: {format}." #: fields.py:1149 msgid "Expected a datetime but got a date." @@ -270,11 +271,11 @@ msgstr "متوقع تاريخ و وقت و وجد تاريخ فقط" #: fields.py:1150 #, python-brace-format msgid "Invalid datetime for the timezone \"{timezone}\"." -msgstr "" +msgstr "تاريخ و وقت غير صالح للمنطقة الزمنية \"{timezone}\"." #: fields.py:1151 msgid "Datetime value out of range." -msgstr "" +msgstr "قيمة التاريخ و الوقت خارج النطاق." #: fields.py:1236 #, python-brace-format @@ -293,12 +294,12 @@ msgstr "صيغة الوقت غير صحيحة. عليك أن تستخدم واح #: fields.py:1365 #, python-brace-format msgid "Duration has wrong format. Use one of these formats instead: {format}." -msgstr "صيغة المدة غير صحيحه, يرجى إستخدام إحدى هذه الصيغ: {format}." +msgstr "صيغة المدة غير صحيحة. يرجى استخدام احد الصيغ التالية: {format}." #: fields.py:1399 fields.py:1456 #, python-brace-format msgid "\"{input}\" is not a valid choice." -msgstr "\"{input}\" ليست واحدة من الخيارات الصالحة." +msgstr "\"{input}\" ليس خياراً صالحاً." #: fields.py:1402 #, python-brace-format @@ -317,7 +318,7 @@ msgstr "هذا التحديد لا يجب أن يكون فارغا." #: fields.py:1495 #, python-brace-format msgid "\"{input}\" is not a valid path choice." -msgstr "{input} كإختيار مسار غير صالح." +msgstr "{input} ليس خيار مسار صالح." #: fields.py:1514 msgid "No file was submitted." @@ -326,41 +327,41 @@ msgstr "لم يتم إرسال أي ملف." #: fields.py:1515 msgid "" "The submitted data was not a file. Check the encoding type on the form." -msgstr "المعطيات المرسولة ليست ملف. إفحص نوع الترميز في النموذج." +msgstr "البيانات المرسلة ليست ملف. تأكد من نوع الترميز في النموذج." #: fields.py:1516 msgid "No filename could be determined." -msgstr "ما من إسم ملف أمكن تحديده." +msgstr "تعذر تحديد اسم الملف." #: fields.py:1517 msgid "The submitted file is empty." -msgstr "الملف الذي تم إرساله فارغ." +msgstr "الملف المرسل فارغ." #: fields.py:1518 #, python-brace-format msgid "" "Ensure this filename has at most {max_length} characters (it has {length})." -msgstr "تأكد ان اسم الملف لا يحوي أكثر من {max_length} محرف (الإسم المرسل يحوي {length} محرف)." +msgstr "تأكد ان طول إسم الملف لا يتجاوز {max_length} حرف (عدد الحروف الحالي {length})." #: fields.py:1566 msgid "" "Upload a valid image. The file you uploaded was either not an image or a " "corrupted image." -msgstr "الرجاء تحميل صورة صالحة. الملف الذي تم تحميله إما لم يكن صورة او انه كان صورة تالفة." +msgstr "يرجى رفع صورة صالحة. الملف الذي قمت برفعه ليس صورة أو أنه ملف تالف." #: fields.py:1604 relations.py:486 serializers.py:571 msgid "This list may not be empty." -msgstr "القائمة يجب أن لا تكون فارغة." +msgstr "يجب أن لا تكون القائمة فارغة." #: fields.py:1605 #, python-brace-format msgid "Ensure this field has at least {min_length} elements." -msgstr "" +msgstr "تأكد ان عدد العناصر في هذا الحقل لا يقل عن {min_length}." #: fields.py:1606 #, python-brace-format msgid "Ensure this field has no more than {max_length} elements." -msgstr "" +msgstr "تأكد ان عدد العناصر في هذا الحقل لا يتجاوز {max_length}." #: fields.py:1682 #, python-brace-format @@ -369,7 +370,7 @@ msgstr "المتوقع كان قاموس عناصر و لكن النوع الم #: fields.py:1683 msgid "This dictionary may not be empty." -msgstr "" +msgstr "يجب أن لا يكون القاموس فارغاً." #: fields.py:1755 msgid "Value must be valid JSON." @@ -381,7 +382,7 @@ msgstr "بحث" #: filters.py:50 msgid "A search term." -msgstr "" +msgstr "مصطلح البحث." #: filters.py:180 templates/rest_framework/filters/ordering.html:3 msgid "Ordering" @@ -389,7 +390,7 @@ msgstr "الترتيب" #: filters.py:181 msgid "Which field to use when ordering the results." -msgstr "" +msgstr "أي حقل يجب استخدامه عند ترتيب النتائج." #: filters.py:287 msgid "ascending" @@ -401,11 +402,11 @@ msgstr "تنازلي" #: pagination.py:174 msgid "A page number within the paginated result set." -msgstr "" +msgstr "رقم الصفحة ضمن النتائج المقسمة." #: pagination.py:179 pagination.py:372 pagination.py:590 msgid "Number of results to return per page." -msgstr "" +msgstr "عدد النتائج التي يجب إرجاعها في كل صفحة." #: pagination.py:189 msgid "Invalid page." @@ -413,11 +414,11 @@ msgstr "صفحة غير صحيحة." #: pagination.py:374 msgid "The initial index from which to return the results." -msgstr "" +msgstr "الفهرس الأولي الذي يجب البدء منه لإرجاع النتائج." #: pagination.py:581 msgid "The pagination cursor value." -msgstr "" +msgstr "قيمة المؤشر للتقسيم." #: pagination.py:583 msgid "Invalid cursor" @@ -431,24 +432,24 @@ msgstr "معرف العنصر \"{pk_value}\" غير صالح - العنصر غ #: relations.py:247 #, python-brace-format msgid "Incorrect type. Expected pk value, received {data_type}." -msgstr "نوع خاطئ. المتوقع قيمة من pk، لكن المتحصل عليه {data_type}." +msgstr "نوع غير صحيح. يتوقع قيمة معرف العنصر، بينما حصل على {data_type}." #: relations.py:280 msgid "Invalid hyperlink - No URL match." -msgstr "إرتباط تشعبي غير صالح - لا مطابقة لURL." +msgstr "رابط تشعبي غير صالح - لا يوجد تطابق URL." #: relations.py:281 msgid "Invalid hyperlink - Incorrect URL match." -msgstr "إرتباط تشعبي غير صالح - مطابقة خاطئة لURL." +msgstr "رابط تشعبي غير صالح - تطابق URL غير صحيح." #: relations.py:282 msgid "Invalid hyperlink - Object does not exist." -msgstr "إرتباط تشعبي غير صالح - عنصر غير موجود." +msgstr "رابط تشعبي غير صالح - العنصر غير موجود." #: relations.py:283 #, python-brace-format msgid "Incorrect type. Expected URL string, received {data_type}." -msgstr "نوع خاطئ. المتوقع سلسلة URL، لكن المتحصل عليه {data_type}." +msgstr "نوع غير صحيح. المتوقع هو رابط URL، ولكن تم الحصول على {data_type}." #: relations.py:448 #, python-brace-format @@ -461,20 +462,20 @@ msgstr "قيمة غير صالحة." #: schemas/utils.py:32 msgid "unique integer value" -msgstr "" +msgstr "رقم صحيح فريد" #: schemas/utils.py:34 msgid "UUID string" -msgstr "" +msgstr "نص UUID" #: schemas/utils.py:36 msgid "unique value" -msgstr "" +msgstr "قيمة فريدة" #: schemas/utils.py:38 #, python-brace-format msgid "A {value_type} identifying this {name}." -msgstr "" +msgstr "نوع {value_type} يحدد هذا {name}." #: serializers.py:337 #, python-brace-format @@ -484,7 +485,7 @@ msgstr "معطيات غير صالحة. المتوقع هو قاموس، لكن #: templates/rest_framework/admin.html:116 #: templates/rest_framework/base.html:136 msgid "Extra Actions" -msgstr "" +msgstr "إجراءات إضافية" #: templates/rest_framework/admin.html:130 #: templates/rest_framework/base.html:150 @@ -493,27 +494,27 @@ msgstr "مرشحات" #: templates/rest_framework/base.html:37 msgid "navbar" -msgstr "" +msgstr "شريط التنقل" #: templates/rest_framework/base.html:75 msgid "content" -msgstr "" +msgstr "المحتوى" #: templates/rest_framework/base.html:78 msgid "request form" -msgstr "" +msgstr "نموذج الطلب" #: templates/rest_framework/base.html:157 msgid "main content" -msgstr "" +msgstr "المحتوى الرئيسي" #: templates/rest_framework/base.html:173 msgid "request info" -msgstr "" +msgstr "معلومات الطلب" #: templates/rest_framework/base.html:177 msgid "response info" -msgstr "" +msgstr "معلومات الرد" #: templates/rest_framework/horizontal/radio.html:4 #: templates/rest_framework/inline/radio.html:3 @@ -525,7 +526,7 @@ msgstr "لا شيء" #: templates/rest_framework/inline/select_multiple.html:3 #: templates/rest_framework/vertical/select_multiple.html:3 msgid "No items to select." -msgstr "ما من عناصر للتحديد." +msgstr "لا يوجد عناصر لتحديدها." #: validators.py:39 msgid "This field must be unique." @@ -539,7 +540,7 @@ msgstr "الحقول {field_names} يجب أن تشكل مجموعة فريدة. #: validators.py:171 #, python-brace-format msgid "Surrogate characters are not allowed: U+{code_point:X}." -msgstr "" +msgstr "لا يُسمح بالحروف البديلة: U+{code_point:X}." #: validators.py:243 #, python-brace-format @@ -558,11 +559,11 @@ msgstr "الحقل يجب ان يكون فريد للعام {date_field}." #: versioning.py:40 msgid "Invalid version in \"Accept\" header." -msgstr "إصدار غير صالح في الرٱس \"Accept\"." +msgstr "إصدار غير صالح في ترويسة \"Accept\"." #: versioning.py:71 msgid "Invalid version in URL path." -msgstr "إصدار غير صالح في المسار URL." +msgstr "نسخة غير صالحة في مسار URL." #: versioning.py:116 msgid "Invalid version in URL path. Does not match any version namespace." diff --git a/rest_framework/locale/de/LC_MESSAGES/django.mo b/rest_framework/locale/de/LC_MESSAGES/django.mo index 986880397..99bdec2c0 100644 Binary files a/rest_framework/locale/de/LC_MESSAGES/django.mo and b/rest_framework/locale/de/LC_MESSAGES/django.mo differ diff --git a/rest_framework/locale/de/LC_MESSAGES/django.po b/rest_framework/locale/de/LC_MESSAGES/django.po index 12ae5ba18..48e59e879 100644 --- a/rest_framework/locale/de/LC_MESSAGES/django.po +++ b/rest_framework/locale/de/LC_MESSAGES/django.po @@ -11,6 +11,7 @@ # Thomas Tanner, 2015 # Tom Jaster , 2015 # Xavier Ordoquy , 2015 +# stefan6419846, 2025 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" @@ -27,19 +28,19 @@ msgstr "" #: authentication.py:70 msgid "Invalid basic header. No credentials provided." -msgstr "Ungültiger basic header. Keine Zugangsdaten angegeben." +msgstr "Ungültiger Basic Header. Keine Zugangsdaten angegeben." #: authentication.py:73 msgid "Invalid basic header. Credentials string should not contain spaces." -msgstr "Ungültiger basic header. Zugangsdaten sollen keine Leerzeichen enthalten." +msgstr "Ungültiger Basic Header. Zugangsdaten sollen keine Leerzeichen enthalten." #: authentication.py:83 msgid "Invalid basic header. Credentials not correctly base64 encoded." -msgstr "Ungültiger basic header. Zugangsdaten sind nicht korrekt mit base64 kodiert." +msgstr "Ungültiger Basic Header. Zugangsdaten sind nicht korrekt mit base64 kodiert." #: authentication.py:101 msgid "Invalid username/password." -msgstr "Ungültiger Benutzername/Passwort" +msgstr "Ungültiger Benutzername/Passwort." #: authentication.py:104 authentication.py:206 msgid "User inactive or deleted." @@ -47,16 +48,16 @@ msgstr "Benutzer inaktiv oder gelöscht." #: authentication.py:184 msgid "Invalid token header. No credentials provided." -msgstr "Ungültiger token header. Keine Zugangsdaten angegeben." +msgstr "Ungültiger Token Header. Keine Zugangsdaten angegeben." #: authentication.py:187 msgid "Invalid token header. Token string should not contain spaces." -msgstr "Ungültiger token header. Zugangsdaten sollen keine Leerzeichen enthalten." +msgstr "Ungültiger Token Header. Zugangsdaten sollen keine Leerzeichen enthalten." #: authentication.py:193 msgid "" "Invalid token header. Token string should not contain invalid characters." -msgstr "Ungültiger Token Header. Tokens dürfen keine ungültigen Zeichen enthalten." +msgstr "Ungültiger Token Header. Zugangsdaten dürfen keine ungültigen Zeichen enthalten." #: authentication.py:203 msgid "Invalid token." @@ -108,7 +109,7 @@ msgstr "Ein Serverfehler ist aufgetreten." #: exceptions.py:142 msgid "Invalid input." -msgstr "" +msgstr "Ungültige Eingabe." #: exceptions.py:161 msgid "Malformed request." @@ -124,7 +125,7 @@ msgstr "Anmeldedaten fehlen." #: exceptions.py:179 msgid "You do not have permission to perform this action." -msgstr "Sie sind nicht berechtigt diese Aktion durchzuführen." +msgstr "Sie sind nicht berechtigt, diese Aktion durchzuführen." #: exceptions.py:185 msgid "Not found." @@ -151,17 +152,17 @@ msgstr "Die Anfrage wurde gedrosselt." #: exceptions.py:224 #, python-brace-format msgid "Expected available in {wait} second." -msgstr "" +msgstr "Erwarte Verfügbarkeit in {wait} Sekunde." #: exceptions.py:225 #, python-brace-format msgid "Expected available in {wait} seconds." -msgstr "" +msgstr "Erwarte Verfügbarkeit in {wait} Sekunden." #: fields.py:316 relations.py:245 relations.py:279 validators.py:90 #: validators.py:183 msgid "This field is required." -msgstr "Dieses Feld ist erforderlich." +msgstr "Dieses Feld ist zwingend erforderlich." #: fields.py:317 msgid "This field may not be null." @@ -169,11 +170,11 @@ msgstr "Dieses Feld darf nicht null sein." #: fields.py:701 msgid "Must be a valid boolean." -msgstr "" +msgstr "Muss ein gültiger Wahrheitswert sein." #: fields.py:766 msgid "Not a valid string." -msgstr "" +msgstr "Kein gültiger String." #: fields.py:767 msgid "This field may not be blank." @@ -207,7 +208,7 @@ msgstr "Gib ein gültiges \"slug\" aus Buchstaben, Ziffern, Unterstrichen und Mi msgid "" "Enter a valid \"slug\" consisting of Unicode letters, numbers, underscores, " "or hyphens." -msgstr "" +msgstr "Gib ein gültiges \"slug\" aus Unicode-Buchstaben, Ziffern, Unterstrichen und Minuszeichen ein." #: fields.py:854 msgid "Enter a valid URL." @@ -215,11 +216,11 @@ msgstr "Gib eine gültige URL ein." #: fields.py:867 msgid "Must be a valid UUID." -msgstr "" +msgstr "Muss eine gültige UUID sein." #: fields.py:903 msgid "Enter a valid IPv4 or IPv6 address." -msgstr "Geben Sie eine gültige IPv4 oder IPv6 Adresse an" +msgstr "Geben Sie eine gültige IPv4 oder IPv6 Adresse an." #: fields.py:931 msgid "A valid integer is required." @@ -273,11 +274,11 @@ msgstr "Erwarte eine Datums- und Zeitangabe, erhielt aber ein Datum." #: fields.py:1150 #, python-brace-format msgid "Invalid datetime for the timezone \"{timezone}\"." -msgstr "" +msgstr "Ungültige Datumsangabe für die Zeitzone \"{timezone}\"." #: fields.py:1151 msgid "Datetime value out of range." -msgstr "" +msgstr "Datumsangabe außerhalb des Bereichs." #: fields.py:1236 #, python-brace-format @@ -358,12 +359,12 @@ msgstr "Diese Liste darf nicht leer sein." #: fields.py:1605 #, python-brace-format msgid "Ensure this field has at least {min_length} elements." -msgstr "" +msgstr "Dieses Feld muss mindestens {min_length} Einträge enthalten." #: fields.py:1606 #, python-brace-format msgid "Ensure this field has no more than {max_length} elements." -msgstr "" +msgstr "Dieses Feld darf nicht mehr als {max_length} Einträge enthalten." #: fields.py:1682 #, python-brace-format @@ -372,7 +373,7 @@ msgstr "Erwartete ein Dictionary mit Elementen, erhielt aber den Typ \"{input_ty #: fields.py:1683 msgid "This dictionary may not be empty." -msgstr "" +msgstr "Dieses Dictionary darf nicht leer sein." #: fields.py:1755 msgid "Value must be valid JSON." @@ -384,7 +385,7 @@ msgstr "Suche" #: filters.py:50 msgid "A search term." -msgstr "" +msgstr "Ein Suchbegriff." #: filters.py:180 templates/rest_framework/filters/ordering.html:3 msgid "Ordering" @@ -392,7 +393,7 @@ msgstr "Sortierung" #: filters.py:181 msgid "Which field to use when ordering the results." -msgstr "" +msgstr "Feld, das zum Sortieren der Ergebnisse verwendet werden soll." #: filters.py:287 msgid "ascending" @@ -404,11 +405,11 @@ msgstr "Absteigend" #: pagination.py:174 msgid "A page number within the paginated result set." -msgstr "" +msgstr "Eine Seitenzahl in der paginierten Ergebnismenge." #: pagination.py:179 pagination.py:372 pagination.py:590 msgid "Number of results to return per page." -msgstr "" +msgstr "Anzahl der pro Seite zurückzugebenden Ergebnisse." #: pagination.py:189 msgid "Invalid page." @@ -416,11 +417,11 @@ msgstr "Ungültige Seite." #: pagination.py:374 msgid "The initial index from which to return the results." -msgstr "" +msgstr "Der initiale Index, von dem die Ergebnisse zurückgegeben werden sollen." #: pagination.py:581 msgid "The pagination cursor value." -msgstr "" +msgstr "Der Zeigerwert für die Paginierung" #: pagination.py:583 msgid "Invalid cursor" @@ -434,7 +435,7 @@ msgstr "Ungültiger pk \"{pk_value}\" - Object existiert nicht." #: relations.py:247 #, python-brace-format msgid "Incorrect type. Expected pk value, received {data_type}." -msgstr "Falscher Typ. Erwarte pk Wert, erhielt aber {data_type}." +msgstr "Falscher Typ. Erwarte pk-Wert, erhielt aber {data_type}." #: relations.py:280 msgid "Invalid hyperlink - No URL match." @@ -451,7 +452,7 @@ msgstr "Ungültiger Hyperlink - Objekt existiert nicht." #: relations.py:283 #, python-brace-format msgid "Incorrect type. Expected URL string, received {data_type}." -msgstr "Falscher Typ. Erwarte URL Zeichenkette, erhielt aber {data_type}." +msgstr "Falscher Typ. Erwarte URL-Zeichenkette, erhielt aber {data_type}." #: relations.py:448 #, python-brace-format @@ -464,20 +465,20 @@ msgstr "Ungültiger Wert." #: schemas/utils.py:32 msgid "unique integer value" -msgstr "" +msgstr "eindeutiger Ganzzahl-Wert" #: schemas/utils.py:34 msgid "UUID string" -msgstr "" +msgstr "UUID-String" #: schemas/utils.py:36 msgid "unique value" -msgstr "" +msgstr "eindeutiger Wert" #: schemas/utils.py:38 #, python-brace-format msgid "A {value_type} identifying this {name}." -msgstr "" +msgstr "Ein {value_type}, der {name} identifiziert." #: serializers.py:337 #, python-brace-format @@ -487,7 +488,7 @@ msgstr "Ungültige Daten. Dictionary erwartet, aber {datatype} erhalten." #: templates/rest_framework/admin.html:116 #: templates/rest_framework/base.html:136 msgid "Extra Actions" -msgstr "" +msgstr "Zusätzliche Aktionen" #: templates/rest_framework/admin.html:130 #: templates/rest_framework/base.html:150 @@ -496,27 +497,27 @@ msgstr "Filter" #: templates/rest_framework/base.html:37 msgid "navbar" -msgstr "" +msgstr "Navigation" #: templates/rest_framework/base.html:75 msgid "content" -msgstr "" +msgstr "Inhalt" #: templates/rest_framework/base.html:78 msgid "request form" -msgstr "" +msgstr "Anfrage-Formular" #: templates/rest_framework/base.html:157 msgid "main content" -msgstr "" +msgstr "Hauptteil" #: templates/rest_framework/base.html:173 msgid "request info" -msgstr "" +msgstr "Anfrage-Informationen" #: templates/rest_framework/base.html:177 msgid "response info" -msgstr "" +msgstr "Antwort-Informationen" #: templates/rest_framework/horizontal/radio.html:4 #: templates/rest_framework/inline/radio.html:3 @@ -542,7 +543,7 @@ msgstr "Die Felder {field_names} müssen eine eindeutige Menge bilden." #: validators.py:171 #, python-brace-format msgid "Surrogate characters are not allowed: U+{code_point:X}." -msgstr "" +msgstr "Ersatzzeichen sind nicht erlaubt: U+{code_point:X}." #: validators.py:243 #, python-brace-format @@ -565,7 +566,7 @@ msgstr "Ungültige Version in der \"Accept\" Kopfzeile." #: versioning.py:71 msgid "Invalid version in URL path." -msgstr "Ungültige Version im URL Pfad." +msgstr "Ungültige Version im URL-Pfad." #: versioning.py:116 msgid "Invalid version in URL path. Does not match any version namespace." diff --git a/rest_framework/locale/fa/LC_MESSAGES/django.mo b/rest_framework/locale/fa/LC_MESSAGES/django.mo index 099318e69..53b8fd98e 100644 Binary files a/rest_framework/locale/fa/LC_MESSAGES/django.mo and b/rest_framework/locale/fa/LC_MESSAGES/django.mo differ diff --git a/rest_framework/locale/fa/LC_MESSAGES/django.po b/rest_framework/locale/fa/LC_MESSAGES/django.po index fd7001d32..8d76372fa 100644 --- a/rest_framework/locale/fa/LC_MESSAGES/django.po +++ b/rest_framework/locale/fa/LC_MESSAGES/django.po @@ -105,7 +105,7 @@ msgstr "خطای سمت سرور رخ داده است." #: exceptions.py:142 msgid "Invalid input." -msgstr "" +msgstr "ورودی نامعتبر" #: exceptions.py:161 msgid "Malformed request." @@ -148,12 +148,12 @@ msgstr "تعداد درخواست‌های شما محدود شده است." #: exceptions.py:224 #, python-brace-format msgid "Expected available in {wait} second." -msgstr "" +msgstr "انتظار می‌رود در {wait} ثانیه در دسترس باشد." #: exceptions.py:225 #, python-brace-format msgid "Expected available in {wait} seconds." -msgstr "" +msgstr "انتظار می‌رود در {wait} ثانیه در دسترس باشد." #: fields.py:316 relations.py:245 relations.py:279 validators.py:90 #: validators.py:183 @@ -166,11 +166,11 @@ msgstr "این مقدار نباید توهی باشد." #: fields.py:701 msgid "Must be a valid boolean." -msgstr "" +msgstr "باید یک مقدار منطقی(بولی) معتبر باشد." #: fields.py:766 msgid "Not a valid string." -msgstr "" +msgstr "یک رشته معتبر نیست." #: fields.py:767 msgid "This field may not be blank." @@ -212,7 +212,7 @@ msgstr "یک URL معتبر وارد کنید" #: fields.py:867 msgid "Must be a valid UUID." -msgstr "" +msgstr "باید یک UUID معتبر باشد." #: fields.py:903 msgid "Enter a valid IPv4 or IPv6 address." @@ -270,11 +270,11 @@ msgstr "باید datetime باشد اما date دریافت شد." #: fields.py:1150 #, python-brace-format msgid "Invalid datetime for the timezone \"{timezone}\"." -msgstr "" +msgstr "تاریخ و زمان برای منطقه زمانی \"{timezone}\" نامعتبر است." #: fields.py:1151 msgid "Datetime value out of range." -msgstr "" +msgstr "مقدار تاریخ و زمان خارج از محدوده است." #: fields.py:1236 #, python-brace-format @@ -355,12 +355,12 @@ msgstr "این لیست نمی تواند خالی باشد" #: fields.py:1605 #, python-brace-format msgid "Ensure this field has at least {min_length} elements." -msgstr "" +msgstr "اطمینان حاصل کنید که این فیلد حداقل {min_length} عنصر دارد." #: fields.py:1606 #, python-brace-format msgid "Ensure this field has no more than {max_length} elements." -msgstr "" +msgstr "اطمینان حاصل کنید که این فیلد بیش از {max_length} عنصر ندارد." #: fields.py:1682 #, python-brace-format @@ -369,7 +369,7 @@ msgstr "باید دیکشنری از آیتم ها ارسال می شد، اما #: fields.py:1683 msgid "This dictionary may not be empty." -msgstr "" +msgstr "این دیکشنری نمی‌تواند خالی باشد." #: fields.py:1755 msgid "Value must be valid JSON." @@ -381,7 +381,7 @@ msgstr "جستجو" #: filters.py:50 msgid "A search term." -msgstr "" +msgstr "یک عبارت جستجو." #: filters.py:180 templates/rest_framework/filters/ordering.html:3 msgid "Ordering" @@ -389,7 +389,7 @@ msgstr "ترتیب" #: filters.py:181 msgid "Which field to use when ordering the results." -msgstr "" +msgstr "کدام فیلد باید هنگام مرتب‌سازی نتایج استفاده شود." #: filters.py:287 msgid "ascending" @@ -401,11 +401,11 @@ msgstr "نزولی" #: pagination.py:174 msgid "A page number within the paginated result set." -msgstr "" +msgstr "یک شماره صفحه‌ در مجموعه نتایج صفحه‌بندی شده." #: pagination.py:179 pagination.py:372 pagination.py:590 msgid "Number of results to return per page." -msgstr "" +msgstr "تعداد نتایج برای نمایش در هر صفحه." #: pagination.py:189 msgid "Invalid page." @@ -413,11 +413,11 @@ msgstr "صفحه نامعتبر" #: pagination.py:374 msgid "The initial index from which to return the results." -msgstr "" +msgstr "ایندکس اولیه‌ای که از آن نتایج بازگردانده می‌شود." #: pagination.py:581 msgid "The pagination cursor value." -msgstr "" +msgstr "مقدار نشانگر صفحه‌بندی." #: pagination.py:583 msgid "Invalid cursor" @@ -461,20 +461,20 @@ msgstr "مقدار نامعتبر." #: schemas/utils.py:32 msgid "unique integer value" -msgstr "" +msgstr "مقداد عدد یکتا" #: schemas/utils.py:34 msgid "UUID string" -msgstr "" +msgstr "رشته UUID" #: schemas/utils.py:36 msgid "unique value" -msgstr "" +msgstr "مقدار یکتا" #: schemas/utils.py:38 #, python-brace-format msgid "A {value_type} identifying this {name}." -msgstr "" +msgstr "یک {value_type} که این {name} را شناسایی میکند." #: serializers.py:337 #, python-brace-format @@ -484,7 +484,7 @@ msgstr "داده نامعتبر. باید دیکشنری ارسال می شد، #: templates/rest_framework/admin.html:116 #: templates/rest_framework/base.html:136 msgid "Extra Actions" -msgstr "" +msgstr "اقدامات اضافی" #: templates/rest_framework/admin.html:130 #: templates/rest_framework/base.html:150 @@ -493,27 +493,27 @@ msgstr "فیلترها" #: templates/rest_framework/base.html:37 msgid "navbar" -msgstr "" +msgstr "نوار ناوبری" #: templates/rest_framework/base.html:75 msgid "content" -msgstr "" +msgstr "محتوا" #: templates/rest_framework/base.html:78 msgid "request form" -msgstr "" +msgstr "فرم درخواست" #: templates/rest_framework/base.html:157 msgid "main content" -msgstr "" +msgstr "محتوای اصلی" #: templates/rest_framework/base.html:173 msgid "request info" -msgstr "" +msgstr "اطلاعات درخواست" #: templates/rest_framework/base.html:177 msgid "response info" -msgstr "" +msgstr "اطلاعات پاسخ" #: templates/rest_framework/horizontal/radio.html:4 #: templates/rest_framework/inline/radio.html:3 @@ -539,7 +539,7 @@ msgstr "فیلدهای {field_names} باید یک مجموعه یکتا باش #: validators.py:171 #, python-brace-format msgid "Surrogate characters are not allowed: U+{code_point:X}." -msgstr "" +msgstr "کاراکترهای جایگزین مجاز نیستند: U+{code_point:X}." #: validators.py:243 #, python-brace-format diff --git a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo index 670228a83..b30686c1f 100644 Binary files a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo and b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo differ diff --git a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po index ce85b52c7..f85c7119e 100644 --- a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po +++ b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po @@ -104,7 +104,7 @@ msgstr "服务器出现了错误。" #: exceptions.py:142 msgid "Invalid input." -msgstr "" +msgstr "无效的输入。" #: exceptions.py:161 msgid "Malformed request." @@ -142,17 +142,17 @@ msgstr "不支持请求中的媒体类型 “{media_type}”。" #: exceptions.py:223 msgid "Request was throttled." -msgstr "请求超过了限速。" +msgstr "请求已被限流。" #: exceptions.py:224 #, python-brace-format msgid "Expected available in {wait} second." -msgstr "" +msgstr "预计 {wait} 秒后可用。" #: exceptions.py:225 #, python-brace-format msgid "Expected available in {wait} seconds." -msgstr "" +msgstr "预计 {wait} 秒后可用。" #: fields.py:316 relations.py:245 relations.py:279 validators.py:90 #: validators.py:183 @@ -165,11 +165,11 @@ msgstr "该字段不能为 null。" #: fields.py:701 msgid "Must be a valid boolean." -msgstr "" +msgstr "必须是有效的布尔值。" #: fields.py:766 msgid "Not a valid string." -msgstr "" +msgstr "不是有效的字符串。" #: fields.py:767 msgid "This field may not be blank." @@ -203,7 +203,7 @@ msgstr "请输入合法的“短语“,只能包含字母,数字,下划线 msgid "" "Enter a valid \"slug\" consisting of Unicode letters, numbers, underscores, " "or hyphens." -msgstr "" +msgstr "请输入有效的“slug”,由 Unicode 字母、数字、下划线或连字符组成。" #: fields.py:854 msgid "Enter a valid URL." @@ -211,7 +211,7 @@ msgstr "请输入合法的URL。" #: fields.py:867 msgid "Must be a valid UUID." -msgstr "" +msgstr "必须是有效的 UUID。" #: fields.py:903 msgid "Enter a valid IPv4 or IPv6 address." @@ -269,11 +269,11 @@ msgstr "期望为日期时间,获得的是日期。" #: fields.py:1150 #, python-brace-format msgid "Invalid datetime for the timezone \"{timezone}\"." -msgstr "" +msgstr "时区“{timezone}”的时间格式无效。" #: fields.py:1151 msgid "Datetime value out of range." -msgstr "" +msgstr "时间数值超出有效范围。" #: fields.py:1236 #, python-brace-format @@ -354,12 +354,12 @@ msgstr "列表不能为空。" #: fields.py:1605 #, python-brace-format msgid "Ensure this field has at least {min_length} elements." -msgstr "" +msgstr "该字段必须包含至少 {min_length} 个元素。" #: fields.py:1606 #, python-brace-format msgid "Ensure this field has no more than {max_length} elements." -msgstr "" +msgstr "该字段不能超过 {max_length} 个元素。" #: fields.py:1682 #, python-brace-format @@ -368,7 +368,7 @@ msgstr "期望是包含类目的字典,得到类型为 “{input_type}”。" #: fields.py:1683 msgid "This dictionary may not be empty." -msgstr "" +msgstr "该字典不能为空。" #: fields.py:1755 msgid "Value must be valid JSON." @@ -380,7 +380,7 @@ msgstr " 搜索" #: filters.py:50 msgid "A search term." -msgstr "" +msgstr "搜索关键词。" #: filters.py:180 templates/rest_framework/filters/ordering.html:3 msgid "Ordering" @@ -388,7 +388,7 @@ msgstr "排序" #: filters.py:181 msgid "Which field to use when ordering the results." -msgstr "" +msgstr "用于排序结果的字段。" #: filters.py:287 msgid "ascending" @@ -400,11 +400,11 @@ msgstr "倒排序" #: pagination.py:174 msgid "A page number within the paginated result set." -msgstr "" +msgstr "分页结果集中的页码。" #: pagination.py:179 pagination.py:372 pagination.py:590 msgid "Number of results to return per page." -msgstr "" +msgstr "每页返回的结果数量。" #: pagination.py:189 msgid "Invalid page." @@ -412,11 +412,11 @@ msgstr "无效页面。" #: pagination.py:374 msgid "The initial index from which to return the results." -msgstr "" +msgstr "返回结果的起始索引位置。" #: pagination.py:581 msgid "The pagination cursor value." -msgstr "" +msgstr "分页游标值" #: pagination.py:583 msgid "Invalid cursor" @@ -460,20 +460,20 @@ msgstr "无效值。" #: schemas/utils.py:32 msgid "unique integer value" -msgstr "" +msgstr "唯一整数值" #: schemas/utils.py:34 msgid "UUID string" -msgstr "" +msgstr "UUID 字符串" #: schemas/utils.py:36 msgid "unique value" -msgstr "" +msgstr "唯一值" #: schemas/utils.py:38 #, python-brace-format msgid "A {value_type} identifying this {name}." -msgstr "" +msgstr "标识此 {name} 的 {value_type}。" #: serializers.py:337 #, python-brace-format @@ -483,7 +483,7 @@ msgstr "无效数据。期待为字典类型,得到的是 {datatype} 。" #: templates/rest_framework/admin.html:116 #: templates/rest_framework/base.html:136 msgid "Extra Actions" -msgstr "" +msgstr "扩展操作" #: templates/rest_framework/admin.html:130 #: templates/rest_framework/base.html:150 @@ -492,27 +492,27 @@ msgstr "过滤器" #: templates/rest_framework/base.html:37 msgid "navbar" -msgstr "" +msgstr "导航栏" #: templates/rest_framework/base.html:75 msgid "content" -msgstr "" +msgstr "内容主体" #: templates/rest_framework/base.html:78 msgid "request form" -msgstr "" +msgstr "请求表单" #: templates/rest_framework/base.html:157 msgid "main content" -msgstr "" +msgstr "主要内容区" #: templates/rest_framework/base.html:173 msgid "request info" -msgstr "" +msgstr "请求信息" #: templates/rest_framework/base.html:177 msgid "response info" -msgstr "" +msgstr "响应信息" #: templates/rest_framework/horizontal/radio.html:4 #: templates/rest_framework/inline/radio.html:3 @@ -538,7 +538,7 @@ msgstr "字段 {field_names} 必须能构成唯一集合。" #: validators.py:171 #, python-brace-format msgid "Surrogate characters are not allowed: U+{code_point:X}." -msgstr "" +msgstr "不允许使用代理字符: U+{code_point:X}。" #: validators.py:243 #, python-brace-format diff --git a/rest_framework/negotiation.py b/rest_framework/negotiation.py index b4bbfa1f5..23012f71f 100644 --- a/rest_framework/negotiation.py +++ b/rest_framework/negotiation.py @@ -65,7 +65,7 @@ class DefaultContentNegotiation(BaseContentNegotiation): full_media_type = ';'.join( (renderer.media_type,) + tuple( - '{}={}'.format(key, value) + f'{key}={value}' for key, value in media_type_wrapper.params.items() ) ) diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 7c15eca58..768f6cb95 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -225,7 +225,7 @@ class DjangoModelPermissions(BasePermission): if hasattr(view, 'get_queryset'): queryset = view.get_queryset() assert queryset is not None, ( - '{}.get_queryset() returned None'.format(view.__class__.__name__) + f'{view.__class__.__name__}.get_queryset() returned None' ) return queryset return view.queryset diff --git a/rest_framework/response.py b/rest_framework/response.py index 6e756544c..507ea595f 100644 --- a/rest_framework/response.py +++ b/rest_framework/response.py @@ -66,7 +66,7 @@ class Response(SimpleTemplateResponse): content_type = self.content_type if content_type is None and charset is not None: - content_type = "{}; charset={}".format(media_type, charset) + content_type = f"{media_type}; charset={charset}" elif content_type is None: content_type = media_type self['Content-Type'] = content_type diff --git a/rest_framework/schemas/coreapi.py b/rest_framework/schemas/coreapi.py index 582aba196..657178304 100644 --- a/rest_framework/schemas/coreapi.py +++ b/rest_framework/schemas/coreapi.py @@ -68,7 +68,7 @@ class LinkNode(dict): current_val = self.methods_counter[preferred_key] self.methods_counter[preferred_key] += 1 - key = '{}_{}'.format(preferred_key, current_val) + key = f'{preferred_key}_{current_val}' if key not in self: return key diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 019eeb33e..eb7dc909d 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -82,7 +82,7 @@ class SchemaGenerator(BaseSchemaGenerator): continue if components_schemas[k] == components[k]: continue - warnings.warn('Schema component "{}" has been overridden with a different value.'.format(k)) + warnings.warn(f'Schema component "{k}" has been overridden with a different value.') components_schemas.update(components) @@ -644,7 +644,7 @@ class AutoSchema(ViewInspector): return self.get_serializer(path, method) def get_reference(self, serializer): - return {'$ref': '#/components/schemas/{}'.format(self.get_component_name(serializer))} + return {'$ref': f'#/components/schemas/{self.get_component_name(serializer)}'} def get_request_body(self, path, method): if method not in ('PUT', 'PATCH', 'POST'): diff --git a/rest_framework/templates/rest_framework/base.html b/rest_framework/templates/rest_framework/base.html index 7f16482b7..e261d8c9d 100644 --- a/rest_framework/templates/rest_framework/base.html +++ b/rest_framework/templates/rest_framework/base.html @@ -176,7 +176,7 @@
HTTP {{ response.status_code }} {{ response.status_text }}{% for key, val in response_headers|items %}
-{{ key }}: {{ val|break_long_headers|urlize }}{% endfor %}
+{{ key }}: {{ val|urlize }}{% endfor %}
 
 {{ content|urlize }}
diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index dba8153b1..3ff74e7cc 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -313,14 +313,3 @@ def smart_urlquote_wrapper(matched_url): return smart_urlquote(matched_url) except ValueError: return None - - -@register.filter -def break_long_headers(header): - """ - Breaks headers longer than 160 characters (~page length) - when possible (are comma separated) - """ - if len(header) > 160 and ',' in header: - header = mark_safe('
' + ',
'.join(escape(header).split(','))) - return header diff --git a/rest_framework/utils/field_mapping.py b/rest_framework/utils/field_mapping.py index fc63f96fe..15c4b9105 100644 --- a/rest_framework/utils/field_mapping.py +++ b/rest_framework/utils/field_mapping.py @@ -66,7 +66,7 @@ def get_unique_validators(field_name, model_field): """ Returns a list of UniqueValidators that should be applied to the field. """ - field_set = set([field_name]) + field_set = {field_name} conditions = { c.condition for c in model_field.model._meta.constraints diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index 0e59aa66a..e6bd84f30 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -1,5 +1,4 @@ import contextlib -import sys from collections.abc import Mapping, MutableMapping from django.utils.encoding import force_str @@ -29,21 +28,20 @@ class ReturnDict(dict): # but preserve the raw data. return (dict, (dict(self),)) - if sys.version_info >= (3, 9): - # These are basically copied from OrderedDict, with `serializer` added. - def __or__(self, other): - if not isinstance(other, dict): - return NotImplemented - new = self.__class__(self, serializer=self.serializer) - new.update(other) - return new + # These are basically copied from OrderedDict, with `serializer` added. + def __or__(self, other): + if not isinstance(other, dict): + return NotImplemented + new = self.__class__(self, serializer=self.serializer) + new.update(other) + return new - def __ror__(self, other): - if not isinstance(other, dict): - return NotImplemented - new = self.__class__(other, serializer=self.serializer) - new.update(self) - return new + def __ror__(self, other): + if not isinstance(other, dict): + return NotImplemented + new = self.__class__(other, serializer=self.serializer) + new.update(self) + return new class ReturnList(list): diff --git a/rest_framework/validators.py b/rest_framework/validators.py index a152c6362..4c444cf01 100644 --- a/rest_framework/validators.py +++ b/rest_framework/validators.py @@ -188,7 +188,8 @@ class UniqueTogetherValidator: if attrs[field_name] != getattr(serializer.instance, field_name) ] - condition_kwargs = {source: attrs[source] for source in self.condition_fields} + condition_sources = (serializer.fields[field_name].source for field_name in self.condition_fields) + condition_kwargs = {source: attrs[source] for source in condition_sources} if checked_values and None not in checked_values and qs_exists_with_condition(queryset, self.condition, condition_kwargs): field_names = ', '.join(self.fields) message = self.message.format(field_names=field_names) diff --git a/setup.py b/setup.py index 952b5f50a..e5e78c2c7 100755 --- a/setup.py +++ b/setup.py @@ -81,7 +81,7 @@ setup( author_email='tom@tomchristie.com', # SEE NOTE BELOW (*) packages=find_packages(exclude=['tests*']), include_package_data=True, - install_requires=["django>=4.2", 'backports.zoneinfo;python_version<"3.9"'], + install_requires=["django>=4.2"], python_requires=">=3.9", zip_safe=False, classifiers=[ diff --git a/tests/schemas/test_coreapi.py b/tests/schemas/test_coreapi.py index 171f08646..a97b02fe1 100644 --- a/tests/schemas/test_coreapi.py +++ b/tests/schemas/test_coreapi.py @@ -1234,7 +1234,7 @@ class TestURLNamingCollisions(TestCase): for method, suffix in zip(methods, suffixes): if suffix is not None: - key = '{}_{}'.format(method, suffix) + key = f'{method}_{suffix}' else: key = method assert loc[key].url == url diff --git a/tests/schemas/test_managementcommand.py b/tests/schemas/test_managementcommand.py index c0713f43c..fa1b75fbf 100644 --- a/tests/schemas/test_managementcommand.py +++ b/tests/schemas/test_managementcommand.py @@ -70,7 +70,7 @@ class GenerateSchemaTests(TestCase): def test_accepts_custom_schema_generator(self): call_command('generateschema', - '--generator_class={}.{}'.format(__name__, CustomSchemaGenerator.__name__), + f'--generator_class={__name__}.{CustomSchemaGenerator.__name__}', stdout=self.out) out_json = yaml.safe_load(self.out.getvalue()) assert out_json == CustomSchemaGenerator.SCHEMA @@ -78,7 +78,7 @@ class GenerateSchemaTests(TestCase): def test_writes_schema_to_file_on_parameter(self): fd, path = tempfile.mkstemp() try: - call_command('generateschema', '--file={}'.format(path), stdout=self.out) + call_command('generateschema', f'--file={path}', stdout=self.out) # nothing on stdout assert not self.out.getvalue() diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 9516bfec9..67be5cfbd 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -43,12 +43,12 @@ class ExceptionTestCase(TestCase): exception = Throttled(wait=2) assert exception.get_full_details() == { - 'message': 'Request was throttled. Expected available in {} seconds.'.format(2), + 'message': f'Request was throttled. Expected available in {2} seconds.', 'code': 'throttled'} exception = Throttled(wait=2, detail='Slow down!') assert exception.get_full_details() == { - 'message': 'Slow down! Expected available in {} seconds.'.format(2), + 'message': f'Slow down! Expected available in {2} seconds.', 'code': 'throttled'} diff --git a/tests/test_fields.py b/tests/test_fields.py index 1403a6a35..d574b07eb 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -2,12 +2,12 @@ import datetime import math import os import re -import sys import uuid import warnings from decimal import ROUND_DOWN, ROUND_UP, Decimal from enum import auto from unittest.mock import patch +from zoneinfo import ZoneInfo import pytest @@ -30,11 +30,6 @@ from rest_framework.fields import ( ) from tests.models import UUIDForeignKeyTarget -if sys.version_info >= (3, 9): - from zoneinfo import ZoneInfo -else: - from backports.zoneinfo import ZoneInfo - utc = datetime.timezone.utc # Tests for helper functions. @@ -641,10 +636,6 @@ class Test5087Regression: class TestTyping(TestCase): - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_field_is_subscriptable(self): assert serializers.Field is serializers.Field["foo"] @@ -671,7 +662,7 @@ class FieldValues: """ for input_value, expected_output in get_items(self.valid_inputs): assert self.field.run_validation(input_value) == expected_output, \ - 'input value: {}'.format(repr(input_value)) + f'input value: {repr(input_value)}' def test_invalid_inputs(self, *args): """ @@ -681,12 +672,12 @@ class FieldValues: with pytest.raises(serializers.ValidationError) as exc_info: self.field.run_validation(input_value) assert exc_info.value.detail == expected_failure, \ - 'input value: {}'.format(repr(input_value)) + f'input value: {repr(input_value)}' def test_outputs(self, *args): for output_value, expected_output in get_items(self.outputs): assert self.field.to_representation(output_value) == expected_output, \ - 'output value: {}'.format(repr(output_value)) + f'output value: {repr(output_value)}' # Boolean types... @@ -1431,7 +1422,7 @@ class TestDateField(FieldValues): outputs = { datetime.date(2001, 1, 1): '2001-01-01', '2001-01-01': '2001-01-01', - str('2016-01-10'): '2016-01-10', + '2016-01-10': '2016-01-10', None: None, '': None, } @@ -1498,7 +1489,7 @@ class TestDateTimeField(FieldValues): datetime.datetime(2001, 1, 1, 13, 00): '2001-01-01T13:00:00Z', datetime.datetime(2001, 1, 1, 13, 00, tzinfo=utc): '2001-01-01T13:00:00Z', '2001-01-01T00:00:00': '2001-01-01T00:00:00', - str('2016-01-10T00:00:00'): '2016-01-10T00:00:00', + '2016-01-10T00:00:00': '2016-01-10T00:00:00', None: None, '': None, } diff --git a/tests/test_generics.py b/tests/test_generics.py index 9990389c9..25b96fcbb 100644 --- a/tests/test_generics.py +++ b/tests/test_generics.py @@ -1,5 +1,3 @@ -import sys - import pytest from django.db import models from django.http import Http404 @@ -291,7 +289,7 @@ class TestInstanceView(TestCase): """ data = {'text': 'foo'} filtered_out_pk = BasicModel.objects.filter(text='filtered out')[0].pk - request = factory.put('/{}'.format(filtered_out_pk), data, format='json') + request = factory.put(f'/{filtered_out_pk}', data, format='json') response = self.view(request, pk=filtered_out_pk).render() assert response.status_code == status.HTTP_404_NOT_FOUND @@ -703,23 +701,11 @@ class TestSerializer(TestCase): class TestTyping(TestCase): - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_genericview_is_subscriptable(self): assert generics.GenericAPIView is generics.GenericAPIView["foo"] - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_listview_is_subscriptable(self): assert generics.ListAPIView is generics.ListAPIView["foo"] - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_instanceview_is_subscriptable(self): assert generics.RetrieveAPIView is generics.RetrieveAPIView["foo"] diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index f1f9518cb..eac51ae70 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -9,7 +9,6 @@ import datetime import decimal import json # noqa import re -import sys import tempfile import pytest @@ -397,10 +396,6 @@ class TestDurationFieldMapping(TestCase): fields = '__all__' expected = dedent(""" - TestSerializer(): - id = IntegerField(label='ID', read_only=True) - duration_field = DurationField(max_value=datetime.timedelta(3), min_value=datetime.timedelta(1)) - """) if sys.version_info < (3, 7) else dedent(""" TestSerializer(): id = IntegerField(label='ID', read_only=True) duration_field = DurationField(max_value=datetime.timedelta(days=3), min_value=datetime.timedelta(days=1)) diff --git a/tests/test_pagination.py b/tests/test_pagination.py index d8feae52b..d8f66e95b 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -536,7 +536,7 @@ class TestLimitOffset: content = self.get_paginated_content(queryset) next_limit = self.pagination.default_limit next_offset = self.pagination.default_limit - next_url = 'http://testserver/?limit={}&offset={}'.format(next_limit, next_offset) + next_url = f'http://testserver/?limit={next_limit}&offset={next_offset}' assert queryset == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] assert content.get('next') == next_url @@ -549,7 +549,7 @@ class TestLimitOffset: content = self.get_paginated_content(queryset) next_limit = self.pagination.default_limit next_offset = self.pagination.default_limit - next_url = 'http://testserver/?limit={}&offset={}'.format(next_limit, next_offset) + next_url = f'http://testserver/?limit={next_limit}&offset={next_offset}' assert queryset == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] assert content.get('next') == next_url @@ -565,9 +565,9 @@ class TestLimitOffset: max_limit = self.pagination.max_limit next_offset = offset + max_limit prev_offset = offset - max_limit - base_url = 'http://testserver/?limit={}'.format(max_limit) - next_url = base_url + '&offset={}'.format(next_offset) - prev_url = base_url + '&offset={}'.format(prev_offset) + base_url = f'http://testserver/?limit={max_limit}' + next_url = base_url + f'&offset={next_offset}' + prev_url = base_url + f'&offset={prev_offset}' assert queryset == list(range(51, 66)) assert content.get('next') == next_url assert content.get('previous') == prev_url diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 2c908ba3f..93fe7b941 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -353,7 +353,7 @@ class ObjectPermissionsIntegrationTests(TestCase): 'delete': f('delete', model_name) } for perm in perms.values(): - perm = '{}.{}'.format(app_label, perm) + perm = f'{app_label}.{perm}' assign_perm(perm, everyone) everyone.user_set.add(*users.values()) @@ -718,7 +718,7 @@ class PermissionsCompositionTests(TestCase): assert hasperm is False def test_operand_holder_is_hashable(self): - assert hash((permissions.IsAuthenticated & permissions.IsAdminUser)) + assert hash(permissions.IsAuthenticated & permissions.IsAdminUser) def test_operand_holder_hash_same_for_same_operands_and_operator(self): first_operand_holder = ( diff --git a/tests/test_relations_pk.py b/tests/test_relations_pk.py index 7a4878a2b..14513f2bb 100644 --- a/tests/test_relations_pk.py +++ b/tests/test_relations_pk.py @@ -586,7 +586,7 @@ class OneToOnePrimaryKeyTests(TestCase): source = OneToOnePKSourceSerializer(data={'name': 'source-2', 'target': target_pk}) # Then: The source is valid with the serializer if not source.is_valid(): - self.fail("Expected OneToOnePKTargetSerializer to be valid but had errors: {}".format(source.errors)) + self.fail(f"Expected OneToOnePKTargetSerializer to be valid but had errors: {source.errors}") # Then: Saving the serializer creates a new object new_source = source.save() # Then: The new object has the same pk as the target object diff --git a/tests/test_renderers.py b/tests/test_renderers.py index d04ff300f..1b396575d 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -408,7 +408,7 @@ class UnicodeJSONRendererTests(TestCase): obj = {'should_escape': '\u2028\u2029'} renderer = JSONRenderer() content = renderer.render(obj, 'application/json') - self.assertEqual(content, '{"should_escape":"\\u2028\\u2029"}'.encode()) + self.assertEqual(content, b'{"should_escape":"\\u2028\\u2029"}') class AsciiJSONRendererTests(TestCase): @@ -421,7 +421,7 @@ class AsciiJSONRendererTests(TestCase): obj = {'countries': ['United Kingdom', 'France', 'España']} renderer = AsciiJSONRenderer() content = renderer.render(obj, 'application/json') - self.assertEqual(content, '{"countries":["United Kingdom","France","Espa\\u00f1a"]}'.encode()) + self.assertEqual(content, b'{"countries":["United Kingdom","France","Espa\\u00f1a"]}') # Tests for caching issue, #346 diff --git a/tests/test_request.py b/tests/test_request.py index 4263f2682..fe3efd96b 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -3,7 +3,6 @@ Tests for content parsing, and form-overloaded content parsing. """ import copy import os.path -import sys import tempfile import pytest @@ -375,9 +374,5 @@ class TestDeepcopy(TestCase): class TestTyping(TestCase): - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_request_is_subscriptable(self): assert Request is Request["foo"] diff --git a/tests/test_response.py b/tests/test_response.py index 00b5691b0..83f8a6717 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -1,6 +1,3 @@ -import sys - -import pytest from django.test import TestCase, override_settings from django.urls import include, path, re_path @@ -270,7 +267,7 @@ class Issue807Tests(TestCase): """ headers = {"HTTP_ACCEPT": RendererC.media_type} resp = self.client.get('/', **headers) - expected = "{}; charset={}".format(RendererC.media_type, RendererC.charset) + expected = f"{RendererC.media_type}; charset={RendererC.charset}" self.assertEqual(expected, resp['Content-Type']) def test_content_type_set_explicitly_on_response(self): @@ -289,9 +286,5 @@ class Issue807Tests(TestCase): class TestTyping(TestCase): - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_response_is_subscriptable(self): assert Response is Response["foo"] diff --git a/tests/test_routers.py b/tests/test_routers.py index 887f601d5..91a6189d5 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -447,9 +447,9 @@ class TestDynamicListAndDetailRouter(TestCase): url_path = endpoint.url_path if method_name.startswith('list_'): - assert route.url == '^{{prefix}}/{0}{{trailing_slash}}$'.format(url_path) + assert route.url == f'^{{prefix}}/{url_path}{{trailing_slash}}$' else: - assert route.url == '^{{prefix}}/{{lookup}}/{0}{{trailing_slash}}$'.format(url_path) + assert route.url == f'^{{prefix}}/{{lookup}}/{url_path}{{trailing_slash}}$' # check method to function mapping if method_name.endswith('_post'): method_map = 'post' @@ -488,14 +488,14 @@ class TestRegexUrlPath(URLPatternsTestCase, TestCase): def test_regex_url_path_list(self): kwarg = '1234' - response = self.client.get('/regex/list/{}/'.format(kwarg)) + response = self.client.get(f'/regex/list/{kwarg}/') assert response.status_code == 200 assert json.loads(response.content.decode()) == {'kwarg': kwarg} def test_regex_url_path_detail(self): pk = '1' kwarg = '1234' - response = self.client.get('/regex/{}/detail/{}/'.format(pk, kwarg)) + response = self.client.get(f'/regex/{pk}/detail/{kwarg}/') assert response.status_code == 200 assert json.loads(response.content.decode()) == {'pk': pk, 'kwarg': kwarg} @@ -557,14 +557,14 @@ class TestUrlPath(URLPatternsTestCase, TestCase): def test_list_extra_action(self): kwarg = 1234 - response = self.client.get('/path/list/{}/'.format(kwarg)) + response = self.client.get(f'/path/list/{kwarg}/') assert response.status_code == 200 assert json.loads(response.content.decode()) == {'kwarg': kwarg} def test_detail_extra_action(self): pk = '1' kwarg = 1234 - response = self.client.get('/path/{}/detail/{}/'.format(pk, kwarg)) + response = self.client.get(f'/path/{pk}/detail/{kwarg}/') assert response.status_code == 200 assert json.loads(response.content.decode()) == {'pk': pk, 'kwarg': kwarg} diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 10fa8afb9..cefa2ee38 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -1,7 +1,6 @@ import inspect import pickle import re -import sys from collections import ChainMap from collections.abc import Mapping @@ -205,10 +204,6 @@ class TestSerializer: exceptions.ErrorDetail(string='Raised error', code='invalid') ]} - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_serializer_is_subscriptable(self): assert serializers.Serializer is serializers.Serializer["foo"] @@ -743,10 +738,6 @@ class TestDeclaredFieldInheritance: class Test8301Regression: - @pytest.mark.skipif( - sys.version_info < (3, 9), - reason="dictionary union operator requires Python 3.9 or higher", - ) def test_ReturnDict_merging(self): # Serializer.data returns ReturnDict, this is essentially a test for that. diff --git a/tests/test_serializer_lists.py b/tests/test_serializer_lists.py index 4070de7a5..42ebf4771 100644 --- a/tests/test_serializer_lists.py +++ b/tests/test_serializer_lists.py @@ -1,5 +1,3 @@ -import sys - import pytest from django.http import QueryDict from django.utils.datastructures import MultiValueDict @@ -60,10 +58,6 @@ class TestListSerializer: assert serializer.is_valid() assert serializer.validated_data == expected_output - @pytest.mark.skipif( - sys.version_info < (3, 7), - reason="subscriptable classes requires Python 3.7 or higher", - ) def test_list_serializer_is_subscriptable(self): assert serializers.ListSerializer is serializers.ListSerializer["foo"] diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py index 4b84f6647..7134c1bae 100644 --- a/tests/test_templatetags.py +++ b/tests/test_templatetags.py @@ -8,8 +8,8 @@ from rest_framework.compat import coreapi, coreschema from rest_framework.relations import Hyperlink from rest_framework.templatetags import rest_framework from rest_framework.templatetags.rest_framework import ( - add_nested_class, add_query_param, as_string, break_long_headers, - format_value, get_pagination_html, schema_links + add_nested_class, add_query_param, as_string, format_value, + get_pagination_html, schema_links ) from rest_framework.test import APIRequestFactory @@ -234,11 +234,6 @@ class TemplateTagTests(TestCase): get_pagination_html(pager) assert pager.called is True - def test_break_long_lines(self): - header = 'long test header,' * 20 - expected_header = '
' + ',
'.join(header.split(',')) - assert break_long_headers(header) == expected_header - class Issue1386Tests(TestCase): """ diff --git a/tests/test_validation.py b/tests/test_validation.py index 6e00b48c2..a2cdd1dcb 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -148,14 +148,14 @@ class TestMaxValueValidatorValidation(TestCase): def test_max_value_validation_success(self): obj = ValidationMaxValueValidatorModel.objects.create(number_value=100) - request = factory.patch('/{}'.format(obj.pk), {'number_value': 98}, format='json') + request = factory.patch(f'/{obj.pk}', {'number_value': 98}, format='json') view = UpdateMaxValueValidationModel().as_view() response = view(request, pk=obj.pk).render() assert response.status_code == status.HTTP_200_OK def test_max_value_validation_fail(self): obj = ValidationMaxValueValidatorModel.objects.create(number_value=100) - request = factory.patch('/{}'.format(obj.pk), {'number_value': 101}, format='json') + request = factory.patch(f'/{obj.pk}', {'number_value': 101}, format='json') view = UpdateMaxValueValidationModel().as_view() response = view(request, pk=obj.pk).render() assert response.content == b'{"number_value":["Ensure this value is less than or equal to 100."]}' diff --git a/tests/test_validators.py b/tests/test_validators.py index 29b097ef3..d19734d98 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -683,6 +683,24 @@ class TestUniqueConstraintValidation(TestCase): result = serializer.save() self.assertIsInstance(result, UniqueConstraintNullableModel) + def test_unique_constraint_source(self): + class SourceUniqueConstraintSerializer(serializers.ModelSerializer): + raceName = serializers.CharField(source="race_name") + + class Meta: + model = UniqueConstraintModel + fields = ("raceName", "position", "global_id", "fancy_conditions") + + serializer = SourceUniqueConstraintSerializer( + data={ + "raceName": "example", + "position": 5, + "global_id": 11, + "fancy_conditions": 11, + } + ) + assert serializer.is_valid() + # Tests for `UniqueForDateValidator` # ----------------------------------