Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api-guide/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ The `allow_null` option is also available for string fields, although its usage

## 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`

Expand Down
2 changes: 1 addition & 1 deletion docs/api-guide/responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

Expand Down
4 changes: 2 additions & 2 deletions docs/api-guide/serializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ When deserializing data, you always need to call `is_valid()` before attempting
serializer.is_valid()
# False
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.

Expand Down Expand Up @@ -298,7 +298,7 @@ When dealing with nested representations that support deserializing the data, an
serializer.is_valid()
# False
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.

Expand Down
2 changes: 1 addition & 1 deletion docs/api-guide/validators.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.

Expand Down
2 changes: 1 addition & 1 deletion docs/community/3.0-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `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):
"""A custom read-only field that returns the class name."""
Expand Down
2 changes: 1 addition & 1 deletion docs/community/3.12-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See [the schema documentation](https://www.django-rest-framework.org/api-guide/s
## Customizing the operation ID.

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.

See [the schema documentation](https://www.django-rest-framework.org/api-guide/schemas/#operationid) for more information.
Expand Down
2 changes: 1 addition & 1 deletion docs/community/3.13-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ They must now use the more explicit keyword argument style...
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.
4 changes: 2 additions & 2 deletions docs/community/3.15-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## 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.

## 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.
4 changes: 2 additions & 2 deletions docs/community/3.16-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ The current minimum versions of Django is now 4.2 and Python 3.9.

## 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

The generation of validators for [UniqueConstraint](https://docs.djangoproject.com/en/stable/ref/models/constraints/#uniqueconstraint) has been improved to support better nullable fields and constraints with conditions.

## 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.
8 changes: 4 additions & 4 deletions docs/community/3.5-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ a dynamic client library to interact with your API.

Finally, we're also now exposing the schema generation as a
[publicly documented API][schema-generation-api], allowing you to more easily
override the behaviour.
override the behavior.

## Requests test client

Expand Down Expand Up @@ -204,18 +204,18 @@ The `'pk'` identifier in schema paths is now mapped onto the actually model fiel
name by default. This will typically be `'id'`.

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__'`.

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.

### Schema action name representations

The internal `retrieve()` and `destroy()` method names are now coerced to an
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.

### DjangoFilterBackend
Expand Down
2 changes: 1 addition & 1 deletion docs/community/3.7-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...

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.schemas import AutoSchema
Expand Down
4 changes: 2 additions & 2 deletions docs/community/3.8-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ If you use REST framework commercially and would like to see this work continue,

## 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.

Previously `read_only` fields when combined with a `default` value would use the `default` for create and update
operations. This was counter-intuitive in some circumstances and led to difficulties supporting dotted `source`
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:

def perform_create(self, serializer):
Expand Down
14 changes: 7 additions & 7 deletions docs/community/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ This release fixes a few bugs, clean-up some old code paths for unsupported Pyth

**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

Expand Down Expand Up @@ -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)]
* 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)]
* 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)]
* 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)]
Expand Down Expand Up @@ -621,27 +621,27 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.
**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.

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:

def perform_create(self, serializer):
serializer.save(owner=self.request.user)

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
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
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:

Expand Down Expand Up @@ -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`.
**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.
**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]
* 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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/browsable-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ The context that's available to the template:
* `FORMAT_PARAM` : The view can accept a format 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

Expand Down