Skip to content

Commit 7efc1b8

Browse files
authored
Merge branch 'main' into unique_togheter_bug
2 parents 6b875ee + 055c422 commit 7efc1b8

File tree

107 files changed

+2313
-1983
lines changed

Some content is hidden

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

107 files changed

+2313
-1983
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ jobs:
1414
strategy:
1515
matrix:
1616
python-version:
17-
- '3.9'
1817
- '3.10'
1918
- '3.11'
2019
- '3.12'
2120
- '3.13'
21+
- '3.14'
2222

2323
steps:
24-
- uses: actions/checkout@v5
24+
- uses: actions/checkout@v6
2525

2626
- uses: actions/setup-python@v6
2727
with:
2828
python-version: ${{ matrix.python-version }}
29+
allow-prereleases: true
2930
cache: 'pip'
3031
cache-dependency-path: 'requirements/*.txt'
3132

@@ -39,7 +40,7 @@ jobs:
3940
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d . | cut -f 1 -d '-')
4041

4142
- name: Run extra tox targets
42-
if: ${{ matrix.python-version == '3.9' }}
43+
if: ${{ matrix.python-version == '3.13' }}
4344
run: |
4445
tox -e base,dist,docs
4546
@@ -52,11 +53,11 @@ jobs:
5253
name: Test documentation links
5354
runs-on: ubuntu-24.04
5455
steps:
55-
- uses: actions/checkout@v5
56+
- uses: actions/checkout@v6
5657

5758
- uses: actions/setup-python@v6
5859
with:
59-
python-version: '3.9'
60+
python-version: '3.13'
6061

6162
- name: Install dependencies
6263
run: pip install -r requirements/requirements-documentation.txt

.github/workflows/mkdocs-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
concurrency:
2121
group: ${{ github.workflow }}-${{ github.ref }}
2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424
- run: git fetch --no-tags --prune --depth=1 origin gh-pages
2525
- uses: actions/setup-python@v6
2626
with:

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v6
1515
with:
1616
fetch-depth: 0
1717

.pre-commit-config.yaml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-case-conflict
77
- id: check-json
88
- id: check-merge-conflict
99
- id: check-symlinks
1010
- id: check-toml
11-
- repo: https://github.com/pycqa/isort
12-
rev: 5.13.2
11+
- repo: https://github.com/PyCQA/isort
12+
rev: 7.0.0
1313
hooks:
1414
- id: isort
1515
- repo: https://github.com/PyCQA/flake8
16-
rev: 7.0.0
16+
rev: 7.3.0
1717
hooks:
1818
- id: flake8
1919
additional_dependencies:
2020
- flake8-tidy-imports
21+
- flake8-bugbear
2122
- repo: https://github.com/adamchainz/blacken-docs
22-
rev: 1.16.0
23+
rev: 1.20.0
2324
hooks:
2425
- id: blacken-docs
25-
exclude: ^(?!docs).*$
2626
additional_dependencies:
27-
- black==23.1.0
27+
- black==25.9.0
2828
- repo: https://github.com/codespell-project/codespell
2929
# Configuration for codespell is in .codespellrc
30-
rev: v2.2.6
30+
rev: v2.4.1
3131
hooks:
3232
- id: codespell
33+
args: [
34+
"--builtin", "clear,rare,code,names,en-GB_to_en-US",
35+
"--ignore-words", "codespell-ignore-words.txt",
36+
"--skip", "*.css",
37+
]
3338
exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js
34-
39+
additional_dependencies:
40+
# python doesn't come with a toml parser prior to 3.11
41+
- "tomli; python_version < '3.11'"
3542
- repo: https://github.com/asottile/pyupgrade
36-
rev: v3.19.1
43+
rev: v3.21.0
3744
hooks:
3845
- id: pyupgrade
39-
args: ["--py39-plus", "--keep-percent-format"]
46+
args: ["--py310-plus", "--keep-percent-format"]
47+
- repo: https://github.com/tox-dev/pyproject-fmt
48+
rev: v2.11.0
49+
hooks:
50+
- id: pyproject-fmt

MANIFEST.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
include README.md
2-
include LICENSE.md
31
recursive-include tests/ *
4-
recursive-include rest_framework/static *.js *.css *.map *.png *.ico *.eot *.svg *.ttf *.woff *.woff2
5-
recursive-include rest_framework/templates *.html schema.js
6-
recursive-include rest_framework/locale *.mo
72
global-exclude __pycache__
83
global-exclude *.py[co]

README.md

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,6 @@ Full documentation for the project is available at [https://www.django-rest-fram
1010

1111
---
1212

13-
# Funding
14-
15-
REST framework is a *collaboratively funded project*. If you use
16-
REST framework commercially we strongly encourage you to invest in its
17-
continued development by [signing up for a paid plan][funding].
18-
19-
The initial aim is to provide a single full-time position on REST framework.
20-
*Every single sign-up makes a significant impact towards making that possible.*
21-
22-
[![][sentry-img]][sentry-url]
23-
[![][stream-img]][stream-url]
24-
[![][spacinov-img]][spacinov-url]
25-
[![][retool-img]][retool-url]
26-
[![][bitio-img]][bitio-url]
27-
[![][posthog-img]][posthog-url]
28-
[![][cryptapi-img]][cryptapi-url]
29-
[![][fezto-img]][fezto-url]
30-
[![][svix-img]][svix-url]
31-
[![][zuplo-img]][zuplo-url]
32-
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].
34-
35-
---
36-
3713
# Overview
3814

3915
Django REST framework is a powerful and flexible toolkit for building Web APIs.
@@ -54,8 +30,8 @@ Some reasons you might want to use REST framework:
5430

5531
# Requirements
5632

57-
* Python 3.9+
58-
* Django 4.2, 5.0, 5.1, 5.2
33+
* Python 3.10+
34+
* Django 4.2, 5.0, 5.1, 5.2, 6.0
5935

6036
We **highly recommend** and only officially support the latest patch release of
6137
each Python and Django series.
@@ -67,10 +43,11 @@ Install using `pip`...
6743
pip install djangorestframework
6844

6945
Add `'rest_framework'` to your `INSTALLED_APPS` setting.
46+
7047
```python
7148
INSTALLED_APPS = [
72-
...
73-
'rest_framework',
49+
# ...
50+
"rest_framework",
7451
]
7552
```
7653

@@ -99,7 +76,7 @@ from rest_framework import routers, serializers, viewsets
9976
class UserSerializer(serializers.HyperlinkedModelSerializer):
10077
class Meta:
10178
model = User
102-
fields = ['url', 'username', 'email', 'is_staff']
79+
fields = ["url", "username", "email", "is_staff"]
10380

10481

10582
# ViewSets define the view behavior.
@@ -110,13 +87,13 @@ class UserViewSet(viewsets.ModelViewSet):
11087

11188
# Routers provide a way of automatically determining the URL conf.
11289
router = routers.DefaultRouter()
113-
router.register(r'users', UserViewSet)
90+
router.register(r"users", UserViewSet)
11491

11592
# Wire up our API using automatic URL routing.
11693
# Additionally, we include login URLs for the browsable API.
11794
urlpatterns = [
118-
path('', include(router.urls)),
119-
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
95+
path("", include(router.urls)),
96+
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
12097
]
12198
```
12299

@@ -126,15 +103,15 @@ Add the following to your `settings.py` module:
126103

127104
```python
128105
INSTALLED_APPS = [
129-
... # Make sure to include the default installed apps here.
130-
'rest_framework',
106+
# ... make sure to include the default installed apps here.
107+
"rest_framework",
131108
]
132109

133110
REST_FRAMEWORK = {
134111
# Use Django's standard `django.contrib.auth` permissions,
135112
# or allow read-only access for unauthenticated users.
136-
'DEFAULT_PERMISSION_CLASSES': [
137-
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
113+
"DEFAULT_PERMISSION_CLASSES": [
114+
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly",
138115
]
139116
}
140117
```
@@ -188,28 +165,6 @@ Please see the [security policy][security-policy].
188165
[funding]: https://fund.django-rest-framework.org/topics/funding/
189166
[sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors
190167

191-
[sentry-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/sentry-readme.png
192-
[stream-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/stream-readme.png
193-
[spacinov-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/spacinov-readme.png
194-
[retool-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/retool-readme.png
195-
[bitio-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/bitio-readme.png
196-
[posthog-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/posthog-readme.png
197-
[cryptapi-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/cryptapi-readme.png
198-
[fezto-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/fezto-readme.png
199-
[svix-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/svix-premium.png
200-
[zuplo-img]: https://raw.githubusercontent.com/encode/django-rest-framework/main/docs/img/premium/zuplo-readme.png
201-
202-
[sentry-url]: https://getsentry.com/welcome/
203-
[stream-url]: https://getstream.io/?utm_source=DjangoRESTFramework&utm_medium=Webpage_Logo_Ad&utm_content=Developer&utm_campaign=DjangoRESTFramework_Jan2022_HomePage
204-
[spacinov-url]: https://www.spacinov.com/
205-
[retool-url]: https://retool.com/?utm_source=djangorest&utm_medium=sponsorship
206-
[bitio-url]: https://bit.io/jobs?utm_source=DRF&utm_medium=sponsor&utm_campaign=DRF_sponsorship
207-
[posthog-url]: https://posthog.com?utm_source=drf&utm_medium=sponsorship&utm_campaign=open-source-sponsorship
208-
[cryptapi-url]: https://cryptapi.io
209-
[fezto-url]: https://www.fezto.xyz/?utm_source=DjangoRESTFramework
210-
[svix-url]: https://www.svix.com/?utm_source=django-REST&utm_medium=sponsorship
211-
[zuplo-url]: https://zuplo.link/django-gh
212-
213168
[oauth1-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth
214169
[oauth2-section]: https://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit
215170
[serializer-section]: https://www.django-rest-framework.org/api-guide/serializers/#serializers

codespell-ignore-words.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Tim
2+
assertIn
3+
IAM
4+
endcode
5+
deque
6+
thead
7+
lets

docs/api-guide/authentication.md

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ The `request.user` property will typically be set to an instance of the `contrib
1919

2020
The `request.auth` property is used for any additional authentication information, for example, it may be used to represent an authentication token that the request was signed with.
2121

22-
---
23-
24-
**Note:** Don't forget that **authentication by itself won't allow or disallow an incoming request**, it simply identifies the credentials that the request was made with.
22+
!!! note
23+
Don't forget that **authentication by itself won't allow or disallow an incoming request**, it simply identifies the credentials that the request was made with.
2524

26-
For information on how to set up the permission policies for your API please see the [permissions documentation][permission].
27-
28-
---
25+
For information on how to set up the permission policies for your API please see the [permissions documentation][permission].
2926

3027
## How authentication is determined
3128

@@ -122,17 +119,15 @@ Unauthenticated responses that are denied permission will result in an `HTTP 401
122119

123120
WWW-Authenticate: Basic realm="api"
124121

125-
**Note:** If you use `BasicAuthentication` in production you must ensure that your API is only available over `https`. You should also ensure that your API clients will always re-request the username and password at login, and will never store those details to persistent storage.
122+
!!! note
123+
If you use `BasicAuthentication` in production you must ensure that your API is only available over `https`. You should also ensure that your API clients will always re-request the username and password at login, and will never store those details to persistent storage.
126124

127125
## TokenAuthentication
128126

129-
---
130-
131-
**Note:** The token authentication provided by Django REST framework is a fairly simple implementation.
132-
133-
For an implementation which allows more than one token per user, has some tighter security implementation details, and supports token expiry, please see the [Django REST Knox][django-rest-knox] third party package.
127+
!!! note
128+
The token authentication provided by Django REST framework is a fairly simple implementation.
134129

135-
---
130+
For an implementation which allows more than one token per user, has some tighter security implementation details, and supports token expiry, please see the [Django REST Knox][django-rest-knox] third party package.
136131

137132
This authentication scheme uses a simple token-based HTTP Authentication scheme. Token authentication is appropriate for client-server setups, such as native desktop and mobile clients.
138133

@@ -173,11 +168,8 @@ The `curl` command line tool may be useful for testing token authenticated APIs.
173168

174169
curl -X GET http://127.0.0.1:8000/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
175170

176-
---
177-
178-
**Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https`.
179-
180-
---
171+
!!! note
172+
If you use `TokenAuthentication` in production you must ensure that your API is only available over `https`.
181173

182174
### Generating Tokens
183175

@@ -293,7 +285,8 @@ Unauthenticated responses that are denied permission will result in an `HTTP 403
293285

294286
If you're using an AJAX-style API with SessionAuthentication, you'll need to make sure you include a valid CSRF token for any "unsafe" HTTP method calls, such as `PUT`, `PATCH`, `POST` or `DELETE` requests. See the [Django CSRF documentation][csrf-ajax] for more details.
295287

296-
**Warning**: Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.
288+
!!! warning
289+
Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.
297290

298291
CSRF validation in REST framework works slightly differently from standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behavior is not suitable for login views, which should always have CSRF validation applied.
299292

@@ -334,11 +327,8 @@ You *may* also override the `.authenticate_header(self, request)` method. If im
334327

335328
If the `.authenticate_header()` method is not overridden, the authentication scheme will return `HTTP 403 Forbidden` responses when an unauthenticated request is denied access.
336329

337-
---
338-
339-
**Note:** When your custom authenticator is invoked by the request object's `.user` or `.auth` properties, you may see an `AttributeError` re-raised as a `WrappedAttributeError`. This is necessary to prevent the original exception from being suppressed by the outer property access. Python will not recognize that the `AttributeError` originates from your custom authenticator and will instead assume that the request object does not have a `.user` or `.auth` property. These errors should be fixed or otherwise handled by your authenticator.
340-
341-
---
330+
!!! note
331+
When your custom authenticator is invoked by the request object's `.user` or `.auth` properties, you may see an `AttributeError` re-raised as a `WrappedAttributeError`. This is necessary to prevent the original exception from being suppressed by the outer property access. Python will not recognize that the `AttributeError` originates from your custom authenticator and will instead assume that the request object does not have a `.user` or `.auth` property. These errors should be fixed or otherwise handled by your authenticator.
342332

343333
## Example
344334

@@ -426,6 +416,11 @@ HTTP Signature (currently a [IETF draft][http-signature-ietf-draft]) provides a
426416

427417
[Djoser][djoser] library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and uses token-based authentication. This is a ready to use REST implementation of the Django authentication system.
428418

419+
## DRF Auth Kit
420+
421+
[DRF Auth Kit][drf-auth-kit] library provides a modern REST authentication solution with JWT cookies, social login, multi-factor authentication, and comprehensive user management. The package offers full type safety, automatic OpenAPI schema generation with DRF Spectacular. It supports multiple authentication types (JWT, DRF Token, or Custom) and includes built-in internationalization for 50+ languages.
422+
423+
429424
## django-rest-auth / dj-rest-auth
430425

431426
This library provides a set of REST API endpoints for registration, authentication (including social media authentication), password reset, retrieve and update user details, etc. By having these API endpoints, your client apps such as AngularJS, iOS, Android, and others can communicate to your Django backend site independently via REST APIs for user management.
@@ -454,9 +449,9 @@ There are currently two forks of this project.
454449

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

457-
## django-pyoidc
452+
## django-pyoidc
458453

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.
454+
[django_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.
460455

461456
More information can be found in the [Documentation](https://django-pyoidc.readthedocs.io/latest/index.html).
462457

@@ -497,4 +492,5 @@ More information can be found in the [Documentation](https://django-pyoidc.readt
497492
[django-rest-authemail]: https://github.com/celiao/django-rest-authemail
498493
[django-rest-durin]: https://github.com/eshaan7/django-rest-durin
499494
[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
495+
[django-pyoidc]: https://github.com/makinacorpus/django_pyoidc
496+
[drf-auth-kit]: https://github.com/huynguyengl99/drf-auth-kit

docs/api-guide/caching.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def get_user_list(request):
8282
```
8383

8484

85-
**NOTE:** The [`cache_page`][page] decorator only caches the
86-
`GET` and `HEAD` responses with status 200.
85+
!!! note
86+
The [`cache_page`][page] decorator only caches the `GET` and `HEAD` responses with status 200.
8787

8888
[page]: https://docs.djangoproject.com/en/stable/topics/cache/#the-per-view-cache
8989
[cookie]: https://docs.djangoproject.com/en/stable/topics/http/decorators/#django.views.decorators.vary.vary_on_cookie

0 commit comments

Comments
 (0)