diff --git a/api-guide/authentication/index.html b/api-guide/authentication/index.html index 6d6f45c39..6906179b4 100644 --- a/api-guide/authentication/index.html +++ b/api-guide/authentication/index.html @@ -853,7 +853,7 @@ REST_FRAMEWORK = {

JSON Web Token Authentication

JSON Web Token is a fairly new standard which can be used for token-based authentication. Unlike the built-in TokenAuthentication scheme, JWT Authentication doesn't need to use a database to validate a token. A package for JWT authentication is djangorestframework-simplejwt which provides some features as well as a pluggable token blacklist app.

Hawk HTTP Authentication

-

The HawkREST library builds on the Mohawk library to let you work with Hawk signed requests and responses in your API. Hawk lets two parties securely communicate with each other using messages signed by a shared key. It is based on HTTP MAC access authentication (which was based on parts of OAuth 1.0).

+

The HawkREST library builds on the Mohawk library to let you work with Hawk signed requests and responses in your API. 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 (which was based on parts of OAuth 1.0).

HTTP Signature Authentication

HTTP Signature (currently a IETF draft) provides a way to achieve origin authentication and message integrity for HTTP messages. Similar to Amazon's HTTP Signature scheme, used by many of its services, it permits stateless, per-request authentication. Elvio Toccalino maintains the djangorestframework-httpsignature (outdated) package which provides an easy-to-use HTTP Signature Authentication mechanism. You can use the updated fork version of djangorestframework-httpsignature, which is drf-httpsig.

Djoser

diff --git a/api-guide/fields/index.html b/api-guide/fields/index.html index 342ebc0de..d7cb085ae 100644 --- a/api-guide/fields/index.html +++ b/api-guide/fields/index.html @@ -759,7 +759,7 @@ explicitly declare the BooleanField on the serializer class, or use

The allow_null option is also available for string fields, although its usage is discouraged in favor of allow_blank. It is valid to set both allow_blank=True and allow_null=True, but doing so means that there will be two differing types of empty value permissible for string representations, which can lead to data inconsistencies and subtle application bugs.

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

Signature: EmailField(max_length=None, min_length=None, allow_blank=False)

RegexField

@@ -1204,7 +1204,7 @@ OrderedDict([('label', 'Second Example'), -

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:

class NestedCoordinateSerializer(serializers.Serializer):
     x = serializers.IntegerField(source='x_coordinate')
diff --git a/api-guide/relations/index.html b/api-guide/relations/index.html
index 1bf9dfa3a..7ee2b4824 100644
--- a/api-guide/relations/index.html
+++ b/api-guide/relations/index.html
@@ -793,7 +793,7 @@ class AlbumSerializer(serializers.ModelSerializer):
         fields = ['album_name', 'artist', 'tracks']
 

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: Track object>
 >>> Track.objects.create(album=album, order=2, title='What More Can I Say', duration=264)
@@ -803,7 +803,7 @@ class AlbumSerializer(serializers.ModelSerializer):
 >>> serializer = AlbumSerializer(instance=album)
 >>> serializer.data
 {
-    'album_name': 'The Grey Album',
+    'album_name': 'The Gray Album',
     'artist': 'Danger Mouse',
     'tracks': [
         {'order': 1, 'title': 'Public Service Announcement', 'duration': 245},
@@ -835,7 +835,7 @@ class AlbumSerializer(serializers.ModelSerializer):
         return album
 
 >>> data = {
-    'album_name': 'The Grey Album',
+    'album_name': 'The Gray Album',
     'artist': 'Danger Mouse',
     'tracks': [
         {'order': 1, 'title': 'Public Service Announcement', 'duration': 245},
diff --git a/api-guide/renderers/index.html b/api-guide/renderers/index.html
index 36ef882de..36827a7dd 100644
--- a/api-guide/renderers/index.html
+++ b/api-guide/renderers/index.html
@@ -679,7 +679,7 @@ Unlike other renderers, the data passed to the Response does not ne
         return Response({'user': self.object}, template_name='user_detail.html')
 

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 for further examples of TemplateHTMLRenderer usage.

.media_type: text/html

.format: 'html'

diff --git a/api-guide/responses/index.html b/api-guide/responses/index.html index 6d77a2b93..313c18fae 100644 --- a/api-guide/responses/index.html +++ b/api-guide/responses/index.html @@ -502,7 +502,7 @@

Django documentation

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.

Unless you want to heavily customize REST framework for some reason, you should always use an APIView class or @api_view function for views that return Response objects. Doing so ensures that the view can perform content negotiation and select the appropriate renderer for the response, before it is returned from the view.


diff --git a/api-guide/schemas/index.html b/api-guide/schemas/index.html index 0dd3891bf..e9f8b7b3e 100644 --- a/api-guide/schemas/index.html +++ b/api-guide/schemas/index.html @@ -471,7 +471,7 @@ functionality instead. The built-in support will be moved into a separate package and then subsequently retired over the next releases.

As a full-fledged replacement, we recommend the drf-spectacular package. 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 Documenting your API.


diff --git a/api-guide/serializers/index.html b/api-guide/serializers/index.html index 6c657cf05..0dc060098 100644 --- a/api-guide/serializers/index.html +++ b/api-guide/serializers/index.html @@ -706,7 +706,7 @@ class CommentSerializer(serializers.Serializer): serializer.data # {'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
 
 json = JSONRenderer().render(serializer.data)
@@ -792,7 +792,7 @@ serializer = CommentSerializer(comment, data=data)
 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.

When deserializing a list of items, errors will be returned as a list of dictionaries representing each of the deserialized items.

@@ -905,7 +905,7 @@ class CommentSerializer(serializers.Serializer): 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.

Writing .create() methods for nested representations

@@ -1011,7 +1011,7 @@ serializer.data

ModelSerializer

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: