Skip to content

Commit b16826c

Browse files
committed
Merge branch 'master' into migrate_setuppy_to_pryoject.toml
2 parents fd1932c + d181511 commit b16826c

32 files changed

+328
-33
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- '3.11'
2222

2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525

2626
- uses: actions/setup-python@v4
2727
with:
@@ -46,3 +46,27 @@ jobs:
4646
- name: Upload coverage
4747
run: |
4848
codecov -e TOXENV,DJANGO
49+
50+
test-docs:
51+
name: Test documentation links
52+
runs-on: ubuntu-22.04
53+
steps:
54+
- uses: actions/checkout@v3
55+
56+
- uses: actions/setup-python@v4
57+
with:
58+
python-version: '3.9'
59+
60+
- name: Install dependencies
61+
run: pip install -r requirements/requirements-documentation.txt
62+
63+
# Start mkdocs server and wait for it to be ready
64+
- run: mkdocs serve &
65+
- run: WAIT_TIME=0 && until nc -vzw 2 localhost 8000 || [ $WAIT_TIME -eq 5 ]; do sleep $(( WAIT_TIME++ )); done
66+
- run: if [ $WAIT_TIME == 5 ]; then echo cannot start mkdocs server on http://localhost:8000; exit 1; fi
67+
68+
- name: Check links
69+
continue-on-error: true
70+
run: pylinkvalidate.py -P http://localhost:8000/
71+
72+
- run: echo "Done"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to REST framework
22

3-
At this point in it's 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.
3+
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

55
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.
66

docs/api-guide/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ More information can be found in the [Documentation](https://django-rest-durin.r
454454
[basicauth]: https://tools.ietf.org/html/rfc2617
455455
[permission]: permissions.md
456456
[throttling]: throttling.md
457-
[csrf-ajax]: https://docs.djangoproject.com/en/stable/ref/csrf/#ajax
457+
[csrf-ajax]: https://docs.djangoproject.com/en/stable/howto/csrf/#using-csrf-protection-with-ajax
458458
[mod_wsgi_official]: https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIPassAuthorization.html
459459
[django-oauth-toolkit-getting-started]: https://django-oauth-toolkit.readthedocs.io/en/latest/rest-framework/getting_started.html
460460
[django-rest-framework-oauth]: https://jpadilla.github.io/django-rest-framework-oauth/

docs/api-guide/exceptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Note that the exception handler will only be called for responses generated by r
101101

102102
The **base class** for all exceptions raised inside an `APIView` class or `@api_view`.
103103

104-
To provide a custom exception, subclass `APIException` and set the `.status_code`, `.default_detail`, and `default_code` attributes on the class.
104+
To provide a custom exception, subclass `APIException` and set the `.status_code`, `.default_detail`, and `.default_code` attributes on the class.
105105

106106
For example, if your API relies on a third party service that may sometimes be unreachable, you might want to implement an exception for the "503 Service Unavailable" HTTP response code. You could do this like so:
107107

docs/api-guide/fields.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ When serializing the instance, default will be used if the object attribute or d
6868

6969
Note that setting a `default` value implies that the field is not required. Including both the `default` and `required` keyword arguments is invalid and will raise an error.
7070

71+
Notes regarding default value propagation from model to serializer:
72+
73+
All the default values from model will pass as default to the serializer and the options method.
74+
75+
If the default is callable then it will be propagated to & evaluated every time in the serializer but not in options method.
76+
77+
If the value for given field is not given then default value will be present in the serializer and available in serializer's methods. Specified validation on given field will be evaluated on default value as that field will be present in the serializer.
78+
7179
### `allow_null`
7280

7381
Normally an error will be raised if `None` is passed to a serializer field. Set this keyword argument to `True` if `None` should be considered a valid value.
@@ -550,6 +558,12 @@ The `HiddenField` class is usually only needed if you have some validation that
550558

551559
For further examples on `HiddenField` see the [validators](validators.md) documentation.
552560

561+
---
562+
563+
**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).
564+
565+
---
566+
553567
## ModelField
554568

555569
A generic field that can be tied to any arbitrary model field. The `ModelField` class delegates the task of serialization/deserialization to its associated model field. This field can be used to create serializer fields for custom model fields, without having to create a new custom serializer field.

docs/api-guide/validators.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ If you want the date field to be entirely hidden from the user, then use `Hidden
164164

165165
---
166166

167+
---
168+
169+
**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).
170+
171+
---
172+
167173
# Advanced field defaults
168174

169175
Validators that are applied across multiple fields in the serializer can sometimes require a field input that should not be provided by the API client, but that *is* available as input to the validator.

docs/api-guide/viewsets.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ The `action` decorator will route `GET` requests by default, but may also accept
178178
def unset_password(self, request, pk=None):
179179
...
180180

181+
Argument `methods` also supports HTTP methods defined as [HTTPMethod](https://docs.python.org/3/library/http.html#http.HTTPMethod). Example below is identical to the one above:
182+
183+
from http import HTTPMethod
184+
185+
@action(detail=True, methods=[HTTPMethod.POST, HTTPMethod.DELETE])
186+
def unset_password(self, request, pk=None):
187+
...
181188

182189
The decorator allows you to override any viewset-level configuration such as `permission_classes`, `serializer_class`, `filter_backends`...:
183190

docs/community/project-management.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ The following template should be used for the description of the issue, and serv
112112
- [ ] `docs` Python & Django versions
113113
- [ ] Update the translations from [transifex](https://www.django-rest-framework.org/topics/project-management/#translations).
114114
- [ ] Ensure the pull request increments the version to `*.*.*` in [`restframework/__init__.py`](https://github.com/encode/django-rest-framework/blob/master/rest_framework/__init__.py).
115+
- [ ] Ensure documentation validates
116+
- Build and serve docs `mkdocs serve`
117+
- Validate links `pylinkvalidate.py -P http://127.0.0.1:8000`
115118
- [ ] Confirm with @tomchristie that release is finalized and ready to go.
116119
- [ ] Ensure that release date is included in pull request.
117120
- [ ] Merge the release pull request.

docs/community/third-party-packages.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
150150
* [fast-drf] - A model based library for making API development faster and easier.
151151
* [django-requestlogs] - Providing middleware and other helpers for audit logging for REST framework.
152152
* [drf-standardized-errors][drf-standardized-errors] - DRF exception handler to standardize error responses for all API endpoints.
153+
* [drf-api-action][drf-api-action] - uses the power of DRF also as a library functions
153154

154155
[cite]: http://www.software-ecosystems.com/Software_Ecosystems/Ecosystems.html
155156
[cookiecutter]: https://github.com/jpadilla/cookiecutter-django-rest-framework
@@ -241,3 +242,4 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
241242
[fast-drf]: https://github.com/iashraful/fast-drf
242243
[django-requestlogs]: https://github.com/Raekkeri/django-requestlogs
243244
[drf-standardized-errors]: https://github.com/ghazi-git/drf-standardized-errors
245+
[drf-api-action]: https://github.com/Ori-Roza/drf-api-action

docs/community/tutorials-and-resources.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ There are a wide range of resources available for learning and using Django REST
1919
</a>
2020
</div>
2121

22+
## Courses
23+
24+
* [Developing RESTful APIs with Django REST Framework][developing-restful-apis-with-django-rest-framework]
25+
2226
## Tutorials
2327

2428
* [Beginner's Guide to the Django REST Framework][beginners-guide-to-the-django-rest-framework]
@@ -130,3 +134,4 @@ Want your Django REST Framework talk/tutorial/article to be added to our website
130134
[pycon-us-2017]: https://www.youtube.com/watch?v=Rk6MHZdust4
131135
[django-rest-react-valentinog]: https://www.valentinog.com/blog/tutorial-api-django-rest-react/
132136
[doordash-implementing-rest-apis]: https://doordash.engineering/2013/10/07/implementing-rest-apis-with-embedded-privacy/
137+
[developing-restful-apis-with-django-rest-framework]: https://testdriven.io/courses/django-rest-framework/

0 commit comments

Comments
 (0)