Skip to content

Commit b58adec

Browse files
committed
Merge branch 'master' into drop-break-long-headers
2 parents 2445421 + 376026c commit b58adec

106 files changed

Lines changed: 1247 additions & 796 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/1-issue.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ on:
99
jobs:
1010
tests:
1111
name: Python ${{ matrix.python-version }}
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-24.04
1313

1414
strategy:
1515
matrix:
1616
python-version:
17-
- '3.8'
1817
- '3.9'
1918
- '3.10'
2019
- '3.11'
2120
- '3.12'
21+
- '3.13'
2222

2323
steps:
2424
- uses: actions/checkout@v4
@@ -33,23 +33,24 @@ jobs:
3333
run: python -m pip install --upgrade pip setuptools virtualenv wheel
3434

3535
- name: Install dependencies
36-
run: python -m pip install --upgrade codecov tox
36+
run: python -m pip install --upgrade tox
3737

3838
- name: Run tox targets for ${{ matrix.python-version }}
39-
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)
39+
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d . | cut -f 1 -d '-')
4040

4141
- name: Run extra tox targets
4242
if: ${{ matrix.python-version == '3.9' }}
4343
run: |
4444
tox -e base,dist,docs
4545
4646
- name: Upload coverage
47-
run: |
48-
codecov -e TOXENV,DJANGO
47+
uses: codecov/codecov-action@v5
48+
with:
49+
env_vars: TOXENV,DJANGO
4950

5051
test-docs:
5152
name: Test documentation links
52-
runs-on: ubuntu-22.04
53+
runs-on: ubuntu-24.04
5354
steps:
5455
- uses: actions/checkout@v4
5556

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ repos:
3131
hooks:
3232
- id: codespell
3333
exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js
34+
35+
- repo: https://github.com/asottile/pyupgrade
36+
rev: v3.19.1
37+
hooks:
38+
- id: pyupgrade
39+
args: ["--py39-plus", "--keep-percent-format"]

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
At this point in its lifespan we consider Django REST framework to be essentially feature-complete. We may accept pull requests that track the continued development of Django versions, but would prefer not to accept new features or code formatting changes.
44

5-
Apart from minor documentation changes, the [GitHub discussions page](https://github.com/encode/django-rest-framework/discussions) should generally be your starting point. Please only raise an issue or pull request if you've been recommended to do so after discussion.
6-
75
The [Contributing guide in the documentation](https://www.django-rest-framework.org/community/contributing/) gives some more information on our process and code of conduct.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ The initial aim is to provide a single full-time position on REST framework.
2828
[![][cryptapi-img]][cryptapi-url]
2929
[![][fezto-img]][fezto-url]
3030
[![][svix-img]][svix-url]
31+
[![][zuplo-img]][zuplo-url]
3132

32-
Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Sentry][sentry-url], [Stream][stream-url], [Spacinov][spacinov-url], [Retool][retool-url], [bit.io][bitio-url], [PostHog][posthog-url], [CryptAPI][cryptapi-url], [FEZTO][fezto-url], and [Svix][svix-url].
33+
Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Sentry][sentry-url], [Stream][stream-url], [Spacinov][spacinov-url], [Retool][retool-url], [bit.io][bitio-url], [PostHog][posthog-url], [CryptAPI][cryptapi-url], [FEZTO][fezto-url], [Svix][svix-url], and [Zuplo][zuplo-url].
3334

3435
---
3536

@@ -53,8 +54,8 @@ Some reasons you might want to use REST framework:
5354

5455
# Requirements
5556

56-
* Python 3.8+
57-
* Django 5.0, 4.2
57+
* Python 3.9+
58+
* Django 4.2, 5.0, 5.1, 5.2
5859

5960
We **highly recommend** and only officially support the latest patch release of
6061
each Python and Django series.
@@ -196,6 +197,7 @@ Please see the [security policy][security-policy].
196197
[cryptapi-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/cryptapi-readme.png
197198
[fezto-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/fezto-readme.png
198199
[svix-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/svix-premium.png
200+
[zuplo-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/zuplo-readme.png
199201

200202
[sentry-url]: https://getsentry.com/welcome/
201203
[stream-url]: https://getstream.io/?utm_source=DjangoRESTFramework&utm_medium=Webpage_Logo_Ad&utm_content=Developer&utm_campaign=DjangoRESTFramework_Jan2022_HomePage
@@ -206,6 +208,7 @@ Please see the [security policy][security-policy].
206208
[cryptapi-url]: https://cryptapi.io
207209
[fezto-url]: https://www.fezto.xyz/?utm_source=DjangoRESTFramework
208210
[svix-url]: https://www.svix.com/?utm_source=django-REST&utm_medium=sponsorship
211+
[zuplo-url]: https://zuplo.link/django-gh
209212

210213
[oauth1-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth
211214
[oauth2-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit

SECURITY.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
## Reporting a Vulnerability
44

5-
Security issues are handled under the supervision of the [Django security team](https://www.djangoproject.com/foundation/teams/#security-team).
5+
**Please report security issues by emailing security@encode.io**.
66

7-
**Please report security issues by emailing security@djangoproject.com**.
8-
9-
The project maintainers will then work with you to resolve any issues where required, prior to any public disclosure.
7+
The project maintainers will then work with you to resolve any issues where required, prior to any public disclosure.

docs/api-guide/authentication.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ The kind of response that will be used depends on the authentication scheme. Al
9090

9191
Note that when a request may successfully authenticate, but still be denied permission to perform the request, in which case a `403 Permission Denied` response will always be used, regardless of the authentication scheme.
9292

93+
## Django 5.1+ `LoginRequiredMiddleware`
94+
95+
If you're running Django 5.1+ and use the [`LoginRequiredMiddleware`][login-required-middleware], please note that all views from DRF are opted-out of this middleware. This is because the authentication in DRF is based authentication and permissions classes, which may be determined after the middleware has been applied. Additionally, when the request is not authenticated, the middleware redirects the user to the login page, which is not suitable for API requests, where it's preferable to return a 401 status code.
96+
97+
REST framework offers an equivalent mechanism for DRF views via the global settings, `DEFAULT_AUTHENTICATION_CLASSES` and `DEFAULT_PERMISSION_CLASSES`. They should be changed accordingly if you need to enforce that API requests are logged in.
98+
9399
## Apache mod_wsgi specific configuration
94100

95101
Note that if deploying to [Apache using mod_wsgi][mod_wsgi_official], the authorization header is not passed through to a WSGI application by default, as it is assumed that authentication will be handled by Apache, rather than at an application level.
@@ -448,6 +454,12 @@ There are currently two forks of this project.
448454

449455
More information can be found in the [Documentation](https://django-rest-durin.readthedocs.io/en/latest/index.html).
450456

457+
## django-pyoidc
458+
459+
[dango-pyoidc][django_pyoidc] adds support for OpenID Connect (OIDC) authentication. This allows you to delegate user management to an Identity Provider, which can be used to implement Single-Sign-On (SSO). It provides support for most uses-cases, such as customizing how token info are mapped to user models, using OIDC audiences for access control, etc.
460+
461+
More information can be found in the [Documentation](https://django-pyoidc.readthedocs.io/latest/index.html).
462+
451463
[cite]: https://jacobian.org/writing/rest-worst-practices/
452464
[http401]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2
453465
[http403]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4
@@ -484,3 +496,5 @@ More information can be found in the [Documentation](https://django-rest-durin.r
484496
[drfpasswordless]: https://github.com/aaronn/django-rest-framework-passwordless
485497
[django-rest-authemail]: https://github.com/celiao/django-rest-authemail
486498
[django-rest-durin]: https://github.com/eshaan7/django-rest-durin
499+
[login-required-middleware]: https://docs.djangoproject.com/en/stable/ref/middleware/#django.contrib.auth.middleware.LoginRequiredMiddleware
500+
[django-pyoidc] : https://github.com/makinacorpus/django_pyoidc

docs/api-guide/fields.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ Corresponds to `django.db.models.fields.DecimalField`.
291291
* `max_digits` The maximum number of digits allowed in the number. It must be either `None` or an integer greater than or equal to `decimal_places`.
292292
* `decimal_places` The number of decimal places to store with the number.
293293
* `coerce_to_string` Set to `True` if string values should be returned for the representation, or `False` if `Decimal` objects should be returned. Defaults to the same value as the `COERCE_DECIMAL_TO_STRING` settings key, which will be `True` unless overridden. If `Decimal` objects are returned by the serializer, then the final output format will be determined by the renderer. Note that setting `localize` will force the value to `True`.
294-
* `max_value` Validate that the number provided is no greater than this value.
295-
* `min_value` Validate that the number provided is no less than this value.
294+
* `max_value` Validate that the number provided is no greater than this value. Should be an integer or `Decimal` object.
295+
* `min_value` Validate that the number provided is no less than this value. Should be an integer or `Decimal` object.
296296
* `localize` Set to `True` to enable localization of input and output based on the current locale. This will also force `coerce_to_string` to `True`. Defaults to `False`. Note that data formatting is enabled if you have set `USE_L10N=True` in your settings file.
297297
* `rounding` Sets the rounding mode used when quantizing to the configured precision. Valid values are [`decimal` module rounding modes][python-decimal-rounding-modes]. Defaults to `None`.
298298
* `normalize_output` Will normalize the decimal value when serialized. This will strip all trailing zeroes and change the value's precision to the minimum required precision to be able to represent the value without losing data. Defaults to `False`.
@@ -552,7 +552,7 @@ For further examples on `HiddenField` see the [validators](validators.md) docume
552552

553553
---
554554

555-
**Note:** `HiddenField()` does not appear in `partial=True` serializer (when making `PATCH` request). This behavior might change in future, follow updates on [github discussion](https://github.com/encode/django-rest-framework/discussions/8259).
555+
**Note:** `HiddenField()` does not appear in `partial=True` serializer (when making `PATCH` request).
556556

557557
---
558558

docs/api-guide/relations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,16 @@ The [drf-nested-routers package][drf-nested-routers] provides routers and relati
628628

629629
The [rest-framework-generic-relations][drf-nested-relations] library provides read/write serialization for generic foreign keys.
630630

631+
The [rest-framework-gm2m-relations][drf-gm2m-relations] library provides read/write serialization for [django-gm2m][django-gm2m-field].
632+
631633
[cite]: http://users.ece.utexas.edu/~adnan/pike.html
632634
[reverse-relationships]: https://docs.djangoproject.com/en/stable/topics/db/queries/#following-relationships-backward
633635
[routers]: https://www.django-rest-framework.org/api-guide/routers#defaultrouter
634636
[generic-relations]: https://docs.djangoproject.com/en/stable/ref/contrib/contenttypes/#id1
635637
[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
636638
[drf-nested-relations]: https://github.com/Ian-Foote/rest-framework-generic-relations
639+
[drf-gm2m-relations]: https://github.com/mojtabaakbari221b/rest-framework-gm2m-relations
640+
[django-gm2m-field]: https://github.com/tkhyn/django-gm2m
637641
[django-intermediary-manytomany]: https://docs.djangoproject.com/en/stable/topics/db/models/#intermediary-manytomany
638642
[dealing-with-nested-objects]: https://www.django-rest-framework.org/api-guide/serializers/#dealing-with-nested-objects
639643
[to_internal_value]: https://www.django-rest-framework.org/api-guide/serializers/#to_internal_valueself-data

0 commit comments

Comments
 (0)