Standardize spelling to American English in documentation (#9804)

* Standardize spelling to American English (only in .md files)

* Update remaining British english spell words to American english style

* Configures the codespell pre-commit hook to enforce US English consistency
changes:
- Activates the `en-GB_to_en-US` built-in dictionary to flag British spellings
- Created codespell-ignore-words.txt file to ignore specific words
- include `code` and `names` for comprehensive typo checking in technical contexts.
- changed the 'lets' to 'let's'.
This commit is contained in:
Pravin 2025-10-27 22:14:48 +05:30 committed by GitHub
parent 0653a63e6d
commit ade172e1d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
34 changed files with 82 additions and 71 deletions

View File

@ -29,6 +29,11 @@ repos:
rev: v2.4.1 rev: v2.4.1
hooks: hooks:
- id: codespell - id: codespell
args: [
"--builtin", "clear,rare,code,names,en-GB_to_en-US",
"--ignore-words", "codespell-ignore-words.txt",
"--skip", "*.css",
]
exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js
additional_dependencies: additional_dependencies:
# python doesn't come with a toml parser prior to 3.11 # python doesn't come with a toml parser prior to 3.11

View File

@ -0,0 +1,6 @@
Tim
assertIn
IAM
endcode
deque
thead

View File

@ -416,7 +416,7 @@ JSON Web Token is a fairly new standard which can be used for token-based authen
## Hawk HTTP Authentication ## Hawk HTTP Authentication
The [HawkREST][hawkrest] library builds on the [Mohawk][mohawk] library to let you work with [Hawk][hawk] signed requests and responses in your API. [Hawk][hawk] lets two parties securely communicate with each other using messages signed by a shared key. It is based on [HTTP MAC access authentication][mac] (which was based on parts of [OAuth 1.0][oauth-1.0a]). The [HawkREST][hawkrest] library builds on the [Mohawk][mohawk] library to let you work with [Hawk][hawk] signed requests and responses in your API. [Hawk][hawk] let's two parties securely communicate with each other using messages signed by a shared key. It is based on [HTTP MAC access authentication][mac] (which was based on parts of [OAuth 1.0][oauth-1.0a]).
## HTTP Signature Authentication ## HTTP Signature Authentication

View File

@ -180,7 +180,7 @@ The `allow_null` option is also available for string fields, although its usage
## EmailField ## EmailField
A text representation, validates the text to be a valid e-mail address. A text representation, validates the text to be a valid email address.
Corresponds to `django.db.models.fields.EmailField` Corresponds to `django.db.models.fields.EmailField`
@ -762,7 +762,7 @@ suitable for updating our target object. With `source='*'`, the return from
('y_coordinate', 4), ('y_coordinate', 4),
('x_coordinate', 3)]) ('x_coordinate', 3)])
For completeness lets do the same thing again but with the nested serializer For completeness let's do the same thing again but with the nested serializer
approach suggested above: approach suggested above:
class NestedCoordinateSerializer(serializers.Serializer): class NestedCoordinateSerializer(serializers.Serializer):

View File

@ -300,7 +300,7 @@ For example, the following serializer:
Would serialize to a nested representation like this: Would serialize to a nested representation like this:
>>> album = Album.objects.create(album_name="The Grey Album", artist='Danger Mouse') >>> album = Album.objects.create(album_name="The Gray Album", artist='Danger Mouse')
>>> Track.objects.create(album=album, order=1, title='Public Service Announcement', duration=245) >>> Track.objects.create(album=album, order=1, title='Public Service Announcement', duration=245)
<Track: Track object> <Track: Track object>
>>> Track.objects.create(album=album, order=2, title='What More Can I Say', duration=264) >>> Track.objects.create(album=album, order=2, title='What More Can I Say', duration=264)
@ -310,7 +310,7 @@ Would serialize to a nested representation like this:
>>> serializer = AlbumSerializer(instance=album) >>> serializer = AlbumSerializer(instance=album)
>>> serializer.data >>> serializer.data
{ {
'album_name': 'The Grey Album', 'album_name': 'The Gray Album',
'artist': 'Danger Mouse', 'artist': 'Danger Mouse',
'tracks': [ 'tracks': [
{'order': 1, 'title': 'Public Service Announcement', 'duration': 245}, {'order': 1, 'title': 'Public Service Announcement', 'duration': 245},
@ -344,7 +344,7 @@ By default nested serializers are read-only. If you want to support write-operat
return album return album
>>> data = { >>> data = {
'album_name': 'The Grey Album', 'album_name': 'The Gray Album',
'artist': 'Danger Mouse', 'artist': 'Danger Mouse',
'tracks': [ 'tracks': [
{'order': 1, 'title': 'Public Service Announcement', 'duration': 245}, {'order': 1, 'title': 'Public Service Announcement', 'duration': 245},

View File

@ -134,7 +134,7 @@ An example of a view that uses `TemplateHTMLRenderer`:
You can use `TemplateHTMLRenderer` either to return regular HTML pages using REST framework, or to return both HTML and API responses from a single endpoint. You can use `TemplateHTMLRenderer` either to return regular HTML pages using REST framework, or to return both HTML and API responses from a single endpoint.
If you're building websites that use `TemplateHTMLRenderer` along with other renderer classes, you should consider listing `TemplateHTMLRenderer` as the first class in the `renderer_classes` list, so that it will be prioritised first even for browsers that send poorly formed `ACCEPT:` headers. If you're building websites that use `TemplateHTMLRenderer` along with other renderer classes, you should consider listing `TemplateHTMLRenderer` as the first class in the `renderer_classes` list, so that it will be prioritized first even for browsers that send poorly formed `ACCEPT:` headers.
See the [_HTML & Forms_ Topic Page][html-and-forms] for further examples of `TemplateHTMLRenderer` usage. See the [_HTML & Forms_ Topic Page][html-and-forms] for further examples of `TemplateHTMLRenderer` usage.

View File

@ -11,7 +11,7 @@ source:
REST framework supports HTTP content negotiation by providing a `Response` class which allows you to return content that can be rendered into multiple content types, depending on the client request. REST framework supports HTTP content negotiation by providing a `Response` class which allows you to return content that can be rendered into multiple content types, depending on the client request.
The `Response` class subclasses Django's `SimpleTemplateResponse`. `Response` objects are initialised with data, which should consist of native Python primitives. REST framework then uses standard HTTP content negotiation to determine how it should render the final response content. The `Response` class subclasses Django's `SimpleTemplateResponse`. `Response` objects are initialized with data, which should consist of native Python primitives. REST framework then uses standard HTTP content negotiation to determine how it should render the final response content.
There's no requirement for you to use the `Response` class, you can also return regular `HttpResponse` or `StreamingHttpResponse` objects from your views if required. Using the `Response` class simply provides a nicer interface for returning content-negotiated Web API responses, that can be rendered to multiple formats. There's no requirement for you to use the `Response` class, you can also return regular `HttpResponse` or `StreamingHttpResponse` objects from your views if required. Using the `Response` class simply provides a nicer interface for returning content-negotiated Web API responses, that can be rendered to multiple formats.

View File

@ -20,7 +20,7 @@ package and then subsequently retired over the next releases.
As a full-fledged replacement, we recommend the [drf-spectacular] package. As a full-fledged replacement, we recommend the [drf-spectacular] package.
It has extensive support for generating OpenAPI 3 schemas from It has extensive support for generating OpenAPI 3 schemas from
REST framework APIs, with both automatic and customisable options available. REST framework APIs, with both automatic and customizable options available.
For further information please refer to For further information please refer to
[Documenting your API](../topics/documenting-your-api.md#drf-spectacular). [Documenting your API](../topics/documenting-your-api.md#drf-spectacular).

View File

@ -48,7 +48,7 @@ We can now use `CommentSerializer` to serialize a comment, or list of comments.
serializer.data serializer.data
# {'email': 'leila@example.com', 'content': 'foo bar', 'created': '2016-01-27T15:17:10.375877'} # {'email': 'leila@example.com', 'content': 'foo bar', 'created': '2016-01-27T15:17:10.375877'}
At this point we've translated the model instance into Python native datatypes. To finalise the serialization process we render the data into `json`. At this point we've translated the model instance into Python native datatypes. To finalize the serialization process we render the data into `json`.
from rest_framework.renderers import JSONRenderer from rest_framework.renderers import JSONRenderer
@ -155,7 +155,7 @@ When deserializing data, you always need to call `is_valid()` before attempting
serializer.is_valid() serializer.is_valid()
# False # False
serializer.errors serializer.errors
# {'email': ['Enter a valid e-mail address.'], 'created': ['This field is required.']} # {'email': ['Enter a valid email address.'], 'created': ['This field is required.']}
Each key in the dictionary will be the field name, and the values will be lists of strings of any error messages corresponding to that field. The `non_field_errors` key may also be present, and will list any general validation errors. The name of the `non_field_errors` key may be customized using the `NON_FIELD_ERRORS_KEY` REST framework setting. Each key in the dictionary will be the field name, and the values will be lists of strings of any error messages corresponding to that field. The `non_field_errors` key may also be present, and will list any general validation errors. The name of the `non_field_errors` key may be customized using the `NON_FIELD_ERRORS_KEY` REST framework setting.
@ -298,7 +298,7 @@ When dealing with nested representations that support deserializing the data, an
serializer.is_valid() serializer.is_valid()
# False # False
serializer.errors serializer.errors
# {'user': {'email': ['Enter a valid e-mail address.']}, 'created': ['This field is required.']} # {'user': {'email': ['Enter a valid email address.']}, 'created': ['This field is required.']}
Similarly, the `.validated_data` property will include nested data structures. Similarly, the `.validated_data` property will include nested data structures.
@ -430,7 +430,7 @@ The context dictionary can be used within any serializer field logic, such as a
Often you'll want serializer classes that map closely to Django model definitions. Often you'll want serializer classes that map closely to Django model definitions.
The `ModelSerializer` class provides a shortcut that lets you automatically create a `Serializer` class with fields that correspond to the Model fields. The `ModelSerializer` class provides a shortcut that let's you automatically create a `Serializer` class with fields that correspond to the Model fields.
**The `ModelSerializer` class is the same as a regular `Serializer` class, except that**: **The `ModelSerializer` class is the same as a regular `Serializer` class, except that**:

View File

@ -264,7 +264,7 @@ For example...
csrftoken = response.cookies['csrftoken'] csrftoken = response.cookies['csrftoken']
# Interact with the API. # Interact with the API.
response = client.post('http://testserver/organisations/', json={ response = client.post('http://testserver/organizations/', json={
'name': 'MegaCorp', 'name': 'MegaCorp',
'status': 'active' 'status': 'active'
}, headers={'X-CSRFToken': csrftoken}) }, headers={'X-CSRFToken': csrftoken})
@ -292,12 +292,12 @@ The CoreAPIClient allows you to interact with your API using the Python
client = CoreAPIClient() client = CoreAPIClient()
schema = client.get('http://testserver/schema/') schema = client.get('http://testserver/schema/')
# Create a new organisation # Create a new organization
params = {'name': 'MegaCorp', 'status': 'active'} params = {'name': 'MegaCorp', 'status': 'active'}
client.action(schema, ['organisations', 'create'], params) client.action(schema, ['organizations', 'create'], params)
# Ensure that the organisation exists in the listing # Ensure that the organization exists in the listing
data = client.action(schema, ['organisations', 'list']) data = client.action(schema, ['organizations', 'list'])
assert(len(data) == 1) assert(len(data) == 1)
assert(data == [{'name': 'MegaCorp', 'status': 'active'}]) assert(data == [{'name': 'MegaCorp', 'status': 'active'}])

View File

@ -175,7 +175,7 @@ If you want the date field to be entirely hidden from the user, then use `Hidden
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. 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.
For this purposes use `HiddenField`. This field will be present in `validated_data` but *will not* be used in the serializer output representation. For this purposes use `HiddenField`. This field will be present in `validated_data` but *will not* be used in the serializer output representation.
**Note:** Using a `read_only=True` field is excluded from writable fields so it won't use a `default=…` argument. Look [3.8 announcement](https://www.django-rest-framework.org/community/3.8-announcement/#altered-the-behaviour-of-read_only-plus-default-on-field). **Note:** Using a `read_only=True` field is excluded from writable fields so it won't use a `default=…` argument. Look [3.8 announcement](https://www.django-rest-framework.org/community/3.8-announcement/#altered-the-behavior-of-read_only-plus-default-on-field).
REST framework includes a couple of defaults that may be useful in this context. REST framework includes a couple of defaults that may be useful in this context.

View File

@ -632,7 +632,7 @@ The `MultipleChoiceField` class has been added. This field acts like `ChoiceFiel
The `from_native(self, value)` and `to_native(self, data)` method names have been replaced with the more obviously named `to_internal_value(self, data)` and `to_representation(self, value)`. The `from_native(self, value)` and `to_native(self, data)` method names have been replaced with the more obviously named `to_internal_value(self, data)` and `to_representation(self, value)`.
The `field_from_native()` and `field_to_native()` methods are removed. Previously you could use these methods if you wanted to customise the behavior in a way that did not simply lookup the field value from the object. For example... The `field_from_native()` and `field_to_native()` methods are removed. Previously you could use these methods if you wanted to customize the behavior in a way that did not simply lookup the field value from the object. For example...
def field_to_native(self, obj, field_name): def field_to_native(self, obj, field_name):
"""A custom read-only field that returns the class name.""" """A custom read-only field that returns the class name."""

View File

@ -50,7 +50,7 @@ See [the schema documentation](https://www.django-rest-framework.org/api-guide/s
## Customizing the operation ID. ## Customizing the operation ID.
REST framework automatically determines operation IDs to use in OpenAPI REST framework automatically determines operation IDs to use in OpenAPI
schemas. The latest version provides more control for overriding the behaviour schemas. The latest version provides more control for overriding the behavior
used to generate the operation IDs. used to generate the operation IDs.
See [the schema documentation](https://www.django-rest-framework.org/api-guide/schemas/#operationid) for more information. See [the schema documentation](https://www.django-rest-framework.org/api-guide/schemas/#operationid) for more information.
@ -96,7 +96,7 @@ for details on using custom `AutoSchema` subclasses.
## Support for JSONField. ## Support for JSONField.
Django 3.1 deprecated the existing `django.contrib.postgres.fields.JSONField` Django 3.1 deprecated the existing `django.contrib.postgres.fields.JSONField`
in favour of a new database-agnositic `JSONField`. in favor of a new database-agnositic `JSONField`.
REST framework 3.12 now supports this new model field, and `ModelSerializer` REST framework 3.12 now supports this new model field, and `ModelSerializer`
classes will correctly map the model field. classes will correctly map the model field.

View File

@ -50,6 +50,6 @@ They must now use the more explicit keyword argument style...
aliases = serializers.ListField(child=serializers.CharField()) aliases = serializers.ListField(child=serializers.CharField())
``` ```
This change has been made because using positional arguments here *does not* result in the expected behaviour. This change has been made because using positional arguments here *does not* result in the expected behavior.
See Pull Request [#7632](https://github.com/encode/django-rest-framework/pull/7632) for more details. See Pull Request [#7632](https://github.com/encode/django-rest-framework/pull/7632) for more details.

View File

@ -39,12 +39,12 @@ By default the URLs created by `SimpleRouter` use regular expressions. This beha
Dependency on pytz has been removed and deprecation warnings have been added, Django will provide ZoneInfo instances as long as USE_DEPRECATED_PYTZ is not enabled. More info on the migration can be found [in this guide](https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html). Dependency on pytz has been removed and deprecation warnings have been added, Django will provide ZoneInfo instances as long as USE_DEPRECATED_PYTZ is not enabled. More info on the migration can be found [in this guide](https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html).
## Align `SearchFilter` behaviour to `django.contrib.admin` search ## Align `SearchFilter` behavior to `django.contrib.admin` search
Searches now may contain _quoted phrases_ with spaces, each phrase is considered as a single search term, and it will raise a validation error if any null-character is provided in search. See the [Filtering API guide](../api-guide/filtering.md) for more information. Searches now may contain _quoted phrases_ with spaces, each phrase is considered as a single search term, and it will raise a validation error if any null-character is provided in search. See the [Filtering API guide](../api-guide/filtering.md) for more information.
## Other fixes and improvements ## Other fixes and improvements
There are a number of fixes and minor improvements in this release, ranging from documentation, internal infrastructure (typing, testing, requirements, deprecation, etc.), security and overall behaviour. There are a number of fixes and minor improvements in this release, ranging from documentation, internal infrastructure (typing, testing, requirements, deprecation, etc.), security and overall behavior.
See the [release notes](release-notes.md) page for a complete listing. See the [release notes](release-notes.md) page for a complete listing.

View File

@ -29,7 +29,7 @@ The current minimum versions of Django is now 4.2 and Python 3.9.
## Django LoginRequiredMiddleware ## Django LoginRequiredMiddleware
The new `LoginRequiredMiddleware` introduced by Django 5.1 can now be used alongside Django REST Framework, however it is not honored for API views as an equivalent behaviour can be configured via `DEFAULT_AUTHENTICATION_CLASSES`. See [our dedicated section](../api-guide/authentication.md#django-51-loginrequiredmiddleware) in the docs for more information. The new `LoginRequiredMiddleware` introduced by Django 5.1 can now be used alongside Django REST Framework, however it is not honored for API views as an equivalent behavior can be configured via `DEFAULT_AUTHENTICATION_CLASSES`. See [our dedicated section](../api-guide/authentication.md#django-51-loginrequiredmiddleware) in the docs for more information.
## Improved support for UniqueConstraint ## Improved support for UniqueConstraint
@ -37,6 +37,6 @@ The generation of validators for [UniqueConstraint](https://docs.djangoproject.c
## Other fixes and improvements ## Other fixes and improvements
There are a number of fixes and minor improvements in this release, ranging from documentation, internal infrastructure (typing, testing, requirements, deprecation, etc.), security and overall behaviour. There are a number of fixes and minor improvements in this release, ranging from documentation, internal infrastructure (typing, testing, requirements, deprecation, etc.), security and overall behavior.
See the [release notes](release-notes.md) page for a complete listing. See the [release notes](release-notes.md) page for a complete listing.

View File

@ -157,7 +157,7 @@ will result in a list of the available choices being returned in the response.
In cases where there is a relational field, the previous behavior would be In cases where there is a relational field, the previous behavior would be
to return a list of available instances to choose from for that relational field. to return a list of available instances to choose from for that relational field.
In order to minimise exposed information the behavior now is to *not* return In order to minimize exposed information the behavior now is to *not* return
choices information for relational fields. choices information for relational fields.
If you want to override this new behavior you'll need to [implement a custom If you want to override this new behavior you'll need to [implement a custom

View File

@ -81,7 +81,7 @@ a dynamic client library to interact with your API.
Finally, we're also now exposing the schema generation as a Finally, we're also now exposing the schema generation as a
[publicly documented API][schema-generation-api], allowing you to more easily [publicly documented API][schema-generation-api], allowing you to more easily
override the behaviour. override the behavior.
## Requests test client ## Requests test client
@ -106,12 +106,12 @@ client library.
client = CoreAPIClient() client = CoreAPIClient()
schema = client.get('http://testserver/schema/') schema = client.get('http://testserver/schema/')
# Create a new organisation # Create a new organization
params = {'name': 'MegaCorp', 'status': 'active'} params = {'name': 'MegaCorp', 'status': 'active'}
client.action(schema, ['organisations', 'create'], params) client.action(schema, ['organizations', 'create'], params)
# Ensure that the organisation exists in the listing # Ensure that the organization exists in the listing
data = client.action(schema, ['organisations', 'list']) data = client.action(schema, ['organizations', 'list'])
assert(len(data) == 1) assert(len(data) == 1)
assert(data == [{'name': 'MegaCorp', 'status': 'active'}]) assert(data == [{'name': 'MegaCorp', 'status': 'active'}])
@ -204,10 +204,10 @@ The `'pk'` identifier in schema paths is now mapped onto the actually model fiel
name by default. This will typically be `'id'`. name by default. This will typically be `'id'`.
This gives a better external representation for schemas, with less implementation This gives a better external representation for schemas, with less implementation
detail being exposed. It also reflects the behaviour of using a ModelSerializer detail being exposed. It also reflects the behavior of using a ModelSerializer
class with `fields = '__all__'`. class with `fields = '__all__'`.
You can revert to the previous behaviour by setting `'SCHEMA_COERCE_PATH_PK': False` You can revert to the previous behavior by setting `'SCHEMA_COERCE_PATH_PK': False`
in the REST framework settings. in the REST framework settings.
### Schema action name representations ### Schema action name representations
@ -215,7 +215,7 @@ in the REST framework settings.
The internal `retrieve()` and `destroy()` method names are now coerced to an The internal `retrieve()` and `destroy()` method names are now coerced to an
external representation of `read` and `delete`. external representation of `read` and `delete`.
You can revert to the previous behaviour by setting `'SCHEMA_COERCE_METHOD_NAMES': {}` You can revert to the previous behavior by setting `'SCHEMA_COERCE_METHOD_NAMES': {}`
in the REST framework settings. in the REST framework settings.
### DjangoFilterBackend ### DjangoFilterBackend

View File

@ -53,7 +53,7 @@ In order to try to address this we're now adding the ability for per-view custom
Let's take a quick look at using the new functionality... Let's take a quick look at using the new functionality...
The `APIView` class has a `schema` attribute, that is used to control how the Schema for that particular view is generated. The default behaviour is to use the `AutoSchema` class. The `APIView` class has a `schema` attribute, that is used to control how the Schema for that particular view is generated. The default behavior is to use the `AutoSchema` class.
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.schemas import AutoSchema from rest_framework.schemas import AutoSchema

View File

@ -36,7 +36,7 @@ If you use REST framework commercially and would like to see this work continue,
## Breaking Changes ## Breaking Changes
### Altered the behaviour of `read_only` plus `default` on Field. ### Altered the behavior of `read_only` plus `default` on Field.
[#5886][gh5886] `read_only` fields will now **always** be excluded from writable fields. [#5886][gh5886] `read_only` fields will now **always** be excluded from writable fields.
@ -44,7 +44,7 @@ Previously `read_only` fields when combined with a `default` value would use the
operations. This was counter-intuitive in some circumstances and led to difficulties supporting dotted `source` operations. This was counter-intuitive in some circumstances and led to difficulties supporting dotted `source`
attributes on nullable relations. attributes on nullable relations.
In order to maintain the old behaviour you may need to pass the value of `read_only` fields when calling `save()` in In order to maintain the old behavior you may need to pass the value of `read_only` fields when calling `save()` in
the view: the view:
def perform_create(self, serializer): def perform_create(self, serializer):

View File

@ -152,7 +152,7 @@ See [#5990][gh5990].
### `action` decorator replaces `list_route` and `detail_route` ### `action` decorator replaces `list_route` and `detail_route`
Both `list_route` and `detail_route` are now deprecated in favour of the single `action` decorator. Both `list_route` and `detail_route` are now deprecated in favor of the single `action` decorator.
They will be removed entirely in 3.10. They will be removed entirely in 3.10.
The `action` decorator takes a boolean `detail` argument. The `action` decorator takes a boolean `detail` argument.

View File

@ -105,7 +105,7 @@ This release fixes a few bugs, clean-up some old code paths for unsupported Pyth
**Date**: 28th March 2025 **Date**: 28th March 2025
This release is considered a significant release to improve upstream support with Django and Python. Some of these may change the behaviour of existing features and pre-existing behaviour. Specifically, some fixes were added to around the support of `UniqueConstraint` with nullable fields which will improve built-in serializer validation. This release is considered a significant release to improve upstream support with Django and Python. Some of these may change the behavior of existing features and pre-existing behavior. Specifically, some fixes were added to around the support of `UniqueConstraint` with nullable fields which will improve built-in serializer validation.
#### Features #### Features
@ -215,7 +215,7 @@ Date: 15th March 2024
* Partial serializer should not have required fields [[#7563](https://github.com/encode/django-rest-framework/pull/7563)] * Partial serializer should not have required fields [[#7563](https://github.com/encode/django-rest-framework/pull/7563)]
* Propagate 'default' from model field to serializer field. [[#9030](https://github.com/encode/django-rest-framework/pull/9030)] * Propagate 'default' from model field to serializer field. [[#9030](https://github.com/encode/django-rest-framework/pull/9030)]
* Allow to override child.run_validation call in ListSerializer [[#8035](https://github.com/encode/django-rest-framework/pull/8035)] * Allow to override child.run_validation call in ListSerializer [[#8035](https://github.com/encode/django-rest-framework/pull/8035)]
* Align SearchFilter behaviour to django.contrib.admin search [[#9017](https://github.com/encode/django-rest-framework/pull/9017)] * Align SearchFilter behavior to django.contrib.admin search [[#9017](https://github.com/encode/django-rest-framework/pull/9017)]
* Class name added to unknown field error [[#9019](https://github.com/encode/django-rest-framework/pull/9019)] * Class name added to unknown field error [[#9019](https://github.com/encode/django-rest-framework/pull/9019)]
* Fix: Pagination response schemas. [[#9049](https://github.com/encode/django-rest-framework/pull/9049)] * Fix: Pagination response schemas. [[#9049](https://github.com/encode/django-rest-framework/pull/9049)]
* Fix choices in ChoiceField to support IntEnum [[#8955](https://github.com/encode/django-rest-framework/pull/8955)] * Fix choices in ChoiceField to support IntEnum [[#8955](https://github.com/encode/django-rest-framework/pull/8955)]
@ -369,7 +369,7 @@ Date: 28th September 2020
* Add `--file` option to `generateschema` command. [#7130] * Add `--file` option to `generateschema` command. [#7130]
* Support `tags` for OpenAPI schema generation. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#grouping-operations-with-tags). [#7184] * Support `tags` for OpenAPI schema generation. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#grouping-operations-with-tags). [#7184]
* Support customising the operation ID for schema generation. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#operationid). [#7190] * Support customizing the operation ID for schema generation. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#operationid). [#7190]
* Support OpenAPI components for schema generation. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#components). [#7124] * Support OpenAPI components for schema generation. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#components). [#7124]
* The following methods on `AutoSchema` become public API: `get_path_parameters`, `get_pagination_parameters`, `get_filter_parameters`, `get_request_body`, `get_responses`, `get_serializer`, `get_paginator`, `map_serializer`, `map_field`, `map_choice_field`, `map_field_validators`, `allows_filters`. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#autoschema) * The following methods on `AutoSchema` become public API: `get_path_parameters`, `get_pagination_parameters`, `get_filter_parameters`, `get_request_body`, `get_responses`, `get_serializer`, `get_paginator`, `map_serializer`, `map_field`, `map_choice_field`, `map_field_validators`, `allows_filters`. See [the schema docs](https://www.django-rest-framework.org/api-guide/schemas/#autoschema)
* Add support for Django 3.1's database-agnositic `JSONField`. [#7467] * Add support for Django 3.1's database-agnositic `JSONField`. [#7467]
@ -407,7 +407,7 @@ Date: 28th September 2020
* Fix `PrimaryKeyRelatedField` and `HyperlinkedRelatedField` when source field is actually a property. [#7142] * Fix `PrimaryKeyRelatedField` and `HyperlinkedRelatedField` when source field is actually a property. [#7142]
* `Token.generate_key` is now a class method. [#7502] * `Token.generate_key` is now a class method. [#7502]
* `@action` warns if method is wrapped in a decorator that does not preserve information using `@functools.wraps`. [#7098] * `@action` warns if method is wrapped in a decorator that does not preserve information using `@functools.wraps`. [#7098]
* Deprecate `serializers.NullBooleanField` in favour of `serializers.BooleanField` with `allow_null=True` [#7122] * Deprecate `serializers.NullBooleanField` in favor of `serializers.BooleanField` with `allow_null=True` [#7122]
--- ---
@ -417,7 +417,7 @@ Date: 28th September 2020
**Date**: 30th September 2020 **Date**: 30th September 2020
* **Security**: Drop `urlize_quoted_links` template tag in favour of Django's built-in `urlize`. Removes a XSS vulnerability for some kinds of content in the browsable API. * **Security**: Drop `urlize_quoted_links` template tag in favor of Django's built-in `urlize`. Removes a XSS vulnerability for some kinds of content in the browsable API.
### 3.11.1 ### 3.11.1
@ -429,7 +429,7 @@ Date: 28th September 2020
**Date**: 12th December 2019 **Date**: 12th December 2019
* Drop `.set_context` API [in favour of a `requires_context` marker](3.11-announcement.md#validator-default-context). * Drop `.set_context` API [in favor of a `requires_context` marker](3.11-announcement.md#validator-default-context).
* Changed default widget for TextField with choices to select box. [#6892][gh6892] * Changed default widget for TextField with choices to select box. [#6892][gh6892]
* Supported nested writes on non-relational fields, such as JSONField. [#6916][gh6916] * Supported nested writes on non-relational fields, such as JSONField. [#6916][gh6916]
* Include request/response media types in OpenAPI schemas, based on configured parsers/renderers. [#6865][gh6865] * Include request/response media types in OpenAPI schemas, based on configured parsers/renderers. [#6865][gh6865]
@ -621,13 +621,13 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
**Date**: [3rd April 2018][3.8.0-milestone] **Date**: [3rd April 2018][3.8.0-milestone]
* **Breaking Change**: Alter `read_only` plus `default` behaviour. [#5886][gh5886] * **Breaking Change**: Alter `read_only` plus `default` behavior. [#5886][gh5886]
`read_only` fields will now **always** be excluded from writable fields. `read_only` fields will now **always** be excluded from writable fields.
Previously `read_only` fields with a `default` value would use the `default` for create and update operations. Previously `read_only` fields with a `default` value would use the `default` for create and update operations.
In order to maintain the old behaviour you may need to pass the value of `read_only` fields when calling `save()` in In order to maintain the old behavior you may need to pass the value of `read_only` fields when calling `save()` in
the view: the view:
def perform_create(self, serializer): def perform_create(self, serializer):
@ -635,13 +635,13 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
Alternatively you may override `save()` or `create()` or `update()` on the serializer as appropriate. Alternatively you may override `save()` or `create()` or `update()` on the serializer as appropriate.
* Correct allow_null behaviour when required=False [#5888][gh5888] * Correct allow_null behavior when required=False [#5888][gh5888]
Without an explicit `default`, `allow_null` implies a default of `null` for outgoing serialization. Previously such Without an explicit `default`, `allow_null` implies a default of `null` for outgoing serialization. Previously such
fields were being skipped when read-only or otherwise not required. fields were being skipped when read-only or otherwise not required.
**Possible backwards compatibility break** if you were relying on such fields being excluded from the outgoing **Possible backwards compatibility break** if you were relying on such fields being excluded from the outgoing
representation. In order to restore the old behaviour you can override `data` to exclude the field when `None`. representation. In order to restore the old behavior you can override `data` to exclude the field when `None`.
For example: For example:
@ -698,7 +698,7 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
* Add HStoreField, postgres fields tests [#5654][gh5654] * Add HStoreField, postgres fields tests [#5654][gh5654]
* Always fully qualify ValidationError in docs [#5751][gh5751] * Always fully qualify ValidationError in docs [#5751][gh5751]
* Remove unreachable code from ManualSchema [#5766][gh5766] * Remove unreachable code from ManualSchema [#5766][gh5766]
* Allowed customising API documentation code samples [#5752][gh5752] * Allowed customizing API documentation code samples [#5752][gh5752]
* Updated docs to use `pip show` [#5757][gh5757] * Updated docs to use `pip show` [#5757][gh5757]
* Load 'static' instead of 'staticfiles' in templates [#5773][gh5773] * Load 'static' instead of 'staticfiles' in templates [#5773][gh5773]
* Fixed a typo in `fields` docs [#5783][gh5783] * Fixed a typo in `fields` docs [#5783][gh5783]
@ -761,7 +761,7 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
* Schema: Extract method for `manual_fields` processing [#5633][gh5633] * Schema: Extract method for `manual_fields` processing [#5633][gh5633]
Allows for easier customisation of `manual_fields` processing, for example Allows for easier customization of `manual_fields` processing, for example
to provide per-method manual fields. `AutoSchema` adds `get_manual_fields`, to provide per-method manual fields. `AutoSchema` adds `get_manual_fields`,
as the intended override point, and a utility method `update_fields`, to as the intended override point, and a utility method `update_fields`, to
handle by-name field replacement from a list, which, in general, you are not handle by-name field replacement from a list, which, in general, you are not
@ -883,7 +883,7 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
* Don't strip microseconds from `time` when encoding. Makes consistent with `datetime`. * Don't strip microseconds from `time` when encoding. Makes consistent with `datetime`.
**BC Change**: Previously only milliseconds were encoded. [#5440][gh5440] **BC Change**: Previously only milliseconds were encoded. [#5440][gh5440]
* Added `STRICT_JSON` setting (default `True`) to raise exception for the extended float values (`nan`, `inf`, `-inf`) accepted by Python's `json` module. * Added `STRICT_JSON` setting (default `True`) to raise exception for the extended float values (`nan`, `inf`, `-inf`) accepted by Python's `json` module.
**BC Change**: Previously these values would converted to corresponding strings. Set `STRICT_JSON` to `False` to restore the previous behaviour. [#5265][gh5265] **BC Change**: Previously these values would converted to corresponding strings. Set `STRICT_JSON` to `False` to restore the previous behavior. [#5265][gh5265]
* Add support for `page_size` parameter in CursorPaginator class [#5250][gh5250] * Add support for `page_size` parameter in CursorPaginator class [#5250][gh5250]
* Make `DEFAULT_PAGINATION_CLASS` `None` by default. * Make `DEFAULT_PAGINATION_CLASS` `None` by default.
**BC Change**: If your were **just** setting `PAGE_SIZE` to enable pagination you will need to add `DEFAULT_PAGINATION_CLASS`. **BC Change**: If your were **just** setting `PAGE_SIZE` to enable pagination you will need to add `DEFAULT_PAGINATION_CLASS`.
@ -921,10 +921,10 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
* Fix naming collisions in Schema Generation [#5464][gh5464] * Fix naming collisions in Schema Generation [#5464][gh5464]
* Call Django's authenticate function with the request object [#5295][gh5295] * Call Django's authenticate function with the request object [#5295][gh5295]
* Update coreapi JS to 0.1.1 [#5479][gh5479] * Update coreapi JS to 0.1.1 [#5479][gh5479]
* Have `is_list_view` recognise RetrieveModel… views [#5480][gh5480] * Have `is_list_view` recognize RetrieveModel… views [#5480][gh5480]
* Remove Django 1.8 & 1.9 compatibility code [#5481][gh5481] * Remove Django 1.8 & 1.9 compatibility code [#5481][gh5481]
* Remove deprecated schema code from DefaultRouter [#5482][gh5482] * Remove deprecated schema code from DefaultRouter [#5482][gh5482]
* Refactor schema generation to allow per-view customisation. * Refactor schema generation to allow per-view customization.
**BC Change**: `SchemaGenerator.get_serializer_fields` has been refactored as `AutoSchema.get_serializer_fields` and drops the `view` argument [#5354][gh5354] **BC Change**: `SchemaGenerator.get_serializer_fields` has been refactored as `AutoSchema.get_serializer_fields` and drops the `view` argument [#5354][gh5354]
## 3.6.x series ## 3.6.x series

View File

@ -53,7 +53,7 @@ Some reasons you might want to use REST framework:
* [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources. * [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources.
* Customizable all the way down - just use [regular function-based views][functionview-section] if you don't need the [more][generic-views] [powerful][viewsets] [features][routers]. * Customizable all the way down - just use [regular function-based views][functionview-section] if you don't need the [more][generic-views] [powerful][viewsets] [features][routers].
* Extensive documentation, and [great community support][group]. * Extensive documentation, and [great community support][group].
* Used and trusted by internationally recognised companies including [Mozilla][mozilla], [Red Hat][redhat], [Heroku][heroku], and [Eventbrite][eventbrite]. * Used and trusted by internationally recognized companies including [Mozilla][mozilla], [Red Hat][redhat], [Heroku][heroku], and [Eventbrite][eventbrite].
--- ---

View File

@ -181,7 +181,7 @@ The context that's available to the template:
* `FORMAT_PARAM` : The view can accept a format override * `FORMAT_PARAM` : The view can accept a format override
* `METHOD_PARAM` : The view can accept a method override * `METHOD_PARAM` : The view can accept a method override
You can override the `BrowsableAPIRenderer.get_context()` method to customise the context that gets passed to the template. You can override the `BrowsableAPIRenderer.get_context()` method to customize the context that gets passed to the template.
#### Not using base.html #### Not using base.html

View File

@ -32,7 +32,7 @@ REST framework also includes [serialization] and [parser]/[renderer] components
## What REST framework doesn't provide. ## What REST framework doesn't provide.
What REST framework doesn't do is give you machine readable hypermedia formats such as [HAL][hal], [Collection+JSON][collection], [JSON API][json-api] or HTML [microformats] by default, or the ability to auto-magically create fully HATEOAS style APIs that include hypermedia-based form descriptions and semantically labelled hyperlinks. Doing so would involve making opinionated choices about API design that should really remain outside of the framework's scope. What REST framework doesn't do is give you machine readable hypermedia formats such as [HAL][hal], [Collection+JSON][collection], [JSON API][json-api] or HTML [microformats] by default, or the ability to auto-magically create fully HATEOAS style APIs that include hypermedia-based form descriptions and semantically labeled hyperlinks. Doing so would involve making opinionated choices about API design that should really remain outside of the framework's scope.
[cite]: https://vimeo.com/channels/restfest/49503453 [cite]: https://vimeo.com/channels/restfest/49503453
[dissertation]: https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm [dissertation]: https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

View File

@ -1,5 +1,5 @@
""" """
Generic views that provide commonly needed behaviour. Generic views that provide commonly needed behavior.
""" """
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models.query import QuerySet from django.db.models.query import QuerySet

View File

@ -1,7 +1,7 @@
""" """
Basic building blocks for generic class based views. Basic building blocks for generic class based views.
We don't bind behaviour to http method handlers yet, We don't bind behavior to http method handlers yet,
which allows mixin classes to be composed in interesting ways. which allows mixin classes to be composed in interesting ways.
""" """
from rest_framework import status from rest_framework import status

View File

@ -50,7 +50,7 @@ Position conflicts with coreapi.Link for URL path {target_url}.
Attempted to insert link with keys: {keys}. Attempted to insert link with keys: {keys}.
Adjust URLs to avoid naming collision or override `SchemaGenerator.get_keys()` Adjust URLs to avoid naming collision or override `SchemaGenerator.get_keys()`
to customise schema structure. to customize schema structure.
""" """
@ -513,7 +513,7 @@ class AutoSchema(ViewInspector):
Default implementation looks for ModelViewSet or GenericAPIView Default implementation looks for ModelViewSet or GenericAPIView
actions/methods that cause filtering on the default implementation. actions/methods that cause filtering on the default implementation.
Override to adjust behaviour for your view. Override to adjust behavior for your view.
Note: Introduced in v3.7: Initially "private" (i.e. with leading underscore) Note: Introduced in v3.7: Initially "private" (i.e. with leading underscore)
to allow changes based on user experience. to allow changes based on user experience.

View File

@ -86,7 +86,7 @@ class SchemaGenerator(BaseSchemaGenerator):
components_schemas.update(components) components_schemas.update(components)
# Normalise path for any provided mount url. # Normalize path for any provided mount url.
if path.startswith('/'): if path.startswith('/'):
path = path[1:] path = path[1:]
path = urljoin(self.url or '/', path) path = urljoin(self.url or '/', path)

View File

@ -7,7 +7,7 @@ Serialization in REST framework is a two-phase process:
1. Serializers marshal between complex types like model instances, and 1. Serializers marshal between complex types like model instances, and
python primitives. python primitives.
2. The process of marshalling between python primitives and request and 2. The process of marshaling between python primitives and request and
response content is handled by parsers and renderers. response content is handled by parsers and renderers.
""" """

View File

@ -33,7 +33,7 @@ class AnonymousUserTests(TestCase):
@override_settings(ROOT_URLCONF='tests.browsable_api.auth_urls') @override_settings(ROOT_URLCONF='tests.browsable_api.auth_urls')
class DropdownWithAuthTests(TestCase): class DropdownWithAuthTests(TestCase):
"""Tests correct dropdown behaviour with Auth views enabled.""" """Tests correct dropdown behavior with Auth views enabled."""
def setUp(self): def setUp(self):
self.client = APIClient(enforce_csrf_checks=True) self.client = APIClient(enforce_csrf_checks=True)
self.username = 'john' self.username = 'john'
@ -74,7 +74,7 @@ class DropdownWithAuthTests(TestCase):
@override_settings(ROOT_URLCONF='tests.browsable_api.no_auth_urls') @override_settings(ROOT_URLCONF='tests.browsable_api.no_auth_urls')
class NoDropdownWithoutAuthTests(TestCase): class NoDropdownWithoutAuthTests(TestCase):
"""Tests correct dropdown behaviour with Auth views NOT enabled.""" """Tests correct dropdown behavior with Auth views NOT enabled."""
def setUp(self): def setUp(self):
self.client = APIClient(enforce_csrf_checks=True) self.client = APIClient(enforce_csrf_checks=True)
self.username = 'john' self.username = 'john'

View File

@ -28,7 +28,7 @@ urlpatterns = [
class DropdownWithAuthTests(TestCase): class DropdownWithAuthTests(TestCase):
"""Tests correct dropdown behaviour with Auth views enabled.""" """Tests correct dropdown behavior with Auth views enabled."""
@override_settings(ROOT_URLCONF='tests.browsable_api.test_browsable_nested_api') @override_settings(ROOT_URLCONF='tests.browsable_api.test_browsable_nested_api')
def test_login(self): def test_login(self):

View File

@ -332,7 +332,7 @@ class TestInitialWithCallable:
def test_initial_should_accept_callable(self): def test_initial_should_accept_callable(self):
""" """
Follows the default ``Field.initial`` behaviour where they accept a Follows the default ``Field.initial`` behavior where they accept a
callable to produce the initial value""" callable to produce the initial value"""
assert self.serializer.data == { assert self.serializer.data == {
'initial_field': 123, 'initial_field': 123,

View File

@ -287,7 +287,7 @@ class TestNestedListSerializer:
class TestNestedListSerializerAllowEmpty: class TestNestedListSerializerAllowEmpty:
"""Tests the behaviour of allow_empty=False when a ListSerializer is used as a field.""" """Tests the behavior of allow_empty=False when a ListSerializer is used as a field."""
@pytest.mark.parametrize('partial', (False, True)) @pytest.mark.parametrize('partial', (False, True))
def test_allow_empty_true(self, partial): def test_allow_empty_true(self, partial):
@ -643,7 +643,7 @@ class TestSerializerPartialUsage:
class TestEmptyListSerializer: class TestEmptyListSerializer:
""" """
Tests the behaviour of ListSerializers when there is no data passed to it Tests the behavior of ListSerializers when there is no data passed to it
""" """
def setup_method(self): def setup_method(self):
@ -672,7 +672,7 @@ class TestEmptyListSerializer:
class TestMaxMinLengthListSerializer: class TestMaxMinLengthListSerializer:
""" """
Tests the behaviour of ListSerializers when max_length and min_length are used Tests the behavior of ListSerializers when max_length and min_length are used
""" """
def setup_method(self): def setup_method(self):