--
cgit v1.2.3
From 6da9d5aee09aecbfb7afdacdd2e445e7c30c5999 Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Wed, 29 Oct 2014 21:26:51 +0000
Subject: Add a workaround for not having the index name
---
docs/theme/base.html | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/docs/theme/base.html b/docs/theme/base.html
index bb3ede2a..d8ff0e07 100644
--- a/docs/theme/base.html
+++ b/docs/theme/base.html
@@ -49,7 +49,8 @@ a.fusion-poweredby {
}
-
+ {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
+
{% endfor %}
{% endfor %}
+
+ {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
+ {% if current_page.input_path == 'index.md' %}
+
+
+
+
+ {% endif %}
+
--
cgit v1.2.3
From b443f81481815423d0f953ca41052b4993dfb12f Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Wed, 29 Oct 2014 22:29:11 +0000
Subject: Add meta description
---
docs/theme/base.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/theme/base.html b/docs/theme/base.html
index d8ff0e07..5187d581 100644
--- a/docs/theme/base.html
+++ b/docs/theme/base.html
@@ -6,7 +6,7 @@
-
+
--
cgit v1.2.3
From 5d479c20d8b9a376057517a4d53d58ff891f5483 Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Wed, 29 Oct 2014 22:29:41 +0000
Subject: Move nav to it's own template based on the MkDocs theme
---
docs/theme/base.html | 93 +---------------------------------------------------
docs/theme/nav.html | 45 +++++++++++++++++++++++++
2 files changed, 46 insertions(+), 92 deletions(-)
create mode 100644 docs/theme/nav.html
diff --git a/docs/theme/base.html b/docs/theme/base.html
index 5187d581..4ca6cd81 100644
--- a/docs/theme/base.html
+++ b/docs/theme/base.html
@@ -54,98 +54,7 @@ a.fusion-poweredby {
- {% endfor %}
- {% endfor %}
-
- {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
- {% if current_page.input_path == 'index.md' %}
-
+ {% endfor %}
+ {% endfor %}
+
+ {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
+ {% if current_page.input_path == 'index.md' %}
+
'
return Response(data)
@@ -300,7 +300,7 @@ The following is an example plaintext renderer that will return a response with
class PlainTextRenderer(renderers.BaseRenderer):
media_type = 'text/plain'
format = 'txt'
-
+
def render(self, data, media_type=None, renderer_context=None):
return data.encode(self.charset)
@@ -340,7 +340,7 @@ You can do some pretty flexible things using REST framework's renderers. Some e
* Provide either flat or nested representations from the same endpoint, depending on the requested media type.
* Serve both regular HTML webpages, and JSON based API responses from the same endpoints.
* Specify multiple types of HTML representation for API clients to use.
-* Underspecify a renderer's media type, such as using `media_type = 'image/*'`, and use the `Accept` header to vary the encoding of the response.
+* Underspecify a renderer's media type, such as using `media_type = 'image/*'`, and use the `Accept` header to vary the encoding of the response.
## Varying behaviour by media type
diff --git a/docs/api-guide/requests.md b/docs/api-guide/requests.md
index 87425ed1..8713fa2a 100644
--- a/docs/api-guide/requests.md
+++ b/docs/api-guide/requests.md
@@ -1,4 +1,4 @@
-
+source: request.py
# Requests
@@ -105,7 +105,7 @@ REST framework supports a few browser enhancements such as browser-based `PUT`,
Browser-based `PUT`, `PATCH` and `DELETE` forms are transparently supported.
-For more information see the [browser enhancements documentation].
+For more information see the [browser enhancements documentation].
## .content_type
@@ -115,7 +115,7 @@ You won't typically need to directly access the request's content type, as you'l
If you do need to access the content type of the request you should use the `.content_type` property in preference to using `request.META.get('HTTP_CONTENT_TYPE')`, as it provides transparent support for browser-based non-form content.
-For more information see the [browser enhancements documentation].
+For more information see the [browser enhancements documentation].
## .stream
@@ -125,7 +125,7 @@ You won't typically need to directly access the request's content, as you'll nor
If you do need to access the raw content directly, you should use the `.stream` property in preference to using `request.content`, as it provides transparent support for browser-based non-form content.
-For more information see the [browser enhancements documentation].
+For more information see the [browser enhancements documentation].
---
diff --git a/docs/api-guide/responses.md b/docs/api-guide/responses.md
index 5a42aa92..97f31271 100644
--- a/docs/api-guide/responses.md
+++ b/docs/api-guide/responses.md
@@ -1,4 +1,4 @@
-
+source: response.py
# Responses
@@ -90,6 +90,6 @@ The `Response` class extends `SimpleTemplateResponse`, and all the usual attribu
As with any other `TemplateResponse`, this method is called to render the serialized data of the response into the final response content. When `.render()` is called, the response content will be set to the result of calling the `.render(data, accepted_media_type, renderer_context)` method on the `accepted_renderer` instance.
You won't typically need to call `.render()` yourself, as it's handled by Django's standard response cycle.
-
+
[cite]: https://docs.djangoproject.com/en/dev/ref/template-response/
[statuscodes]: status-codes.md
diff --git a/docs/api-guide/reverse.md b/docs/api-guide/reverse.md
index 383eca4c..71fb83f9 100644
--- a/docs/api-guide/reverse.md
+++ b/docs/api-guide/reverse.md
@@ -1,4 +1,4 @@
-
+source: reverse.py
# Returning URLs
@@ -30,7 +30,7 @@ You should **include the request as a keyword argument** to the function, for ex
from rest_framework.reverse import reverse
from rest_framework.views import APIView
from django.utils.timezone import now
-
+
class APIRootView(APIView):
def get(self, request):
year = now().year
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md
index 61a476b8..080230fa 100644
--- a/docs/api-guide/routers.md
+++ b/docs/api-guide/routers.md
@@ -1,4 +1,4 @@
-
+source: routers.py
# Routers
@@ -56,10 +56,10 @@ For example, given a method like this on the `UserViewSet` class:
from myapp.permissions import IsAdminOrIsSelf
from rest_framework.decorators import detail_route
-
+
class UserViewSet(ModelViewSet):
...
-
+
@detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf])
def set_password(self, request, pk=None):
...
@@ -228,7 +228,7 @@ For another example of setting the `.routes` attribute, see the source code for
## Advanced custom routers
-If you want to provide totally custom behavior, you can override `BaseRouter` and override the `get_urls(self)` method. The method should inspect the registered viewsets and return a list of URL patterns. The registered prefix, viewset and basename tuples may be inspected by accessing the `self.registry` attribute.
+If you want to provide totally custom behavior, you can override `BaseRouter` and override the `get_urls(self)` method. The method should inspect the registered viewsets and return a list of URL patterns. The registered prefix, viewset and basename tuples may be inspected by accessing the `self.registry` attribute.
You may also want to override the `get_default_base_name(self, viewset)` method, or else always explicitly set the `base_name` argument when registering your viewsets with the router.
diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md
index eeeffa13..2d0ff79a 100644
--- a/docs/api-guide/serializers.md
+++ b/docs/api-guide/serializers.md
@@ -1,4 +1,4 @@
-
+source: serializers.py
# Serializers
@@ -21,7 +21,7 @@ Let's start by creating a simple object we can use for example purposes:
self.email = email
self.content = content
self.created = created or datetime.datetime.now()
-
+
comment = Comment(email='leila@example.com', content='foo bar')
We'll declare a serializer that we can use to serialize and deserialize `Comment` objects.
@@ -45,7 +45,7 @@ Declaring a serializer looks very similar to declaring a form:
instance.content = attrs.get('content', instance.content)
instance.created = attrs.get('created', instance.created)
return instance
- return Comment(**attrs)
+ return Comment(**attrs)
The first part of serializer class defines the fields that get serialized/deserialized. The `restore_object` method defines how fully fledged instances get created when deserializing data.
@@ -83,8 +83,8 @@ If you need to customize the serialized value of a particular field, you can do
These methods are essentially the reverse of `validate_` (see *Validation* below.)
## Deserializing objects
-
-Deserialization is similar. First we parse a stream into Python native datatypes...
+
+Deserialization is similar. First we parse a stream into Python native datatypes...
from StringIO import StringIO
from rest_framework.parsers import JSONParser
@@ -174,7 +174,7 @@ To save the deserialized objects created by a serializer, call the `.save()` met
The default behavior of the method is to simply call `.save()` on the deserialized object instance. You can override the default save behaviour by overriding the `.save_object(obj)` method on the serializer class.
-The generic views provided by REST framework call the `.save()` method when updating or creating entities.
+The generic views provided by REST framework call the `.save()` method when updating or creating entities.
## Dealing with nested objects
@@ -288,12 +288,12 @@ By default the serializer class will use the `id` key on the incoming data to de
slug = serializers.CharField(max_length=100)
created = serializers.DateTimeField()
... # Various other fields
-
+
def get_identity(self, data):
"""
This hook is required for bulk update.
We need to override the default, to use the slug as the identity.
-
+
Note that the data has not yet been validated at this point,
so we need to deal gracefully with incorrect datatypes.
"""
@@ -361,7 +361,7 @@ The `depth` option should be set to an integer value that indicates the depth of
If you want to customize the way the serialization is done (e.g. using `allow_add_remove`) you'll need to define the field yourself.
-## Specifying which fields should be read-only
+## Specifying which fields should be read-only
You may wish to specify multiple fields as read-only. Instead of adding each field explicitly with the `read_only=True` attribute, you may use the `read_only_fields` Meta option, like so:
@@ -371,9 +371,9 @@ You may wish to specify multiple fields as read-only. Instead of adding each fi
fields = ('id', 'account_name', 'users', 'created')
read_only_fields = ('account_name',)
-Model fields which have `editable=False` set, and `AutoField` fields will be set to read-only by default, and do not need to be added to the `read_only_fields` option.
+Model fields which have `editable=False` set, and `AutoField` fields will be set to read-only by default, and do not need to be added to the `read_only_fields` option.
-## Specifying which fields should be write-only
+## Specifying which fields should be write-only
You may wish to specify multiple fields as write-only. Instead of adding each field explicitly with the `write_only=True` attribute, you may use the `write_only_fields` Meta option, like so:
@@ -387,12 +387,12 @@ You may wish to specify multiple fields as write-only. Instead of adding each f
"""
Instantiate a new User instance.
"""
- assert instance is None, 'Cannot update users with CreateUserSerializer'
+ assert instance is None, 'Cannot update users with CreateUserSerializer'
user = User(email=attrs['email'], username=attrs['username'])
user.set_password(attrs['password'])
return user
-
-## Specifying fields explicitly
+
+## Specifying fields explicitly
You can add extra fields to a `ModelSerializer` or override the default fields by declaring fields on the class, just as you would for a `Serializer` class.
@@ -524,10 +524,10 @@ For example, if you wanted to be able to set which fields should be used by a se
def __init__(self, *args, **kwargs):
# Don't pass the 'fields' arg up to the superclass
fields = kwargs.pop('fields', None)
-
+
# Instantiate the superclass normally
super(DynamicFieldsModelSerializer, self).__init__(*args, **kwargs)
-
+
if fields:
# Drop any fields that are not specified in the `fields` argument.
allowed = set(fields)
@@ -550,7 +550,7 @@ This would then allow you to do the following:
## Customising the default fields
-The `field_mapping` attribute is a dictionary that maps model classes to serializer classes. Overriding the attribute will let you set a different set of default serializer classes.
+The `field_mapping` attribute is a dictionary that maps model classes to serializer classes. Overriding the attribute will let you set a different set of default serializer classes.
For more advanced customization than simply changing the default serializer class you can override various `get__field` methods. Doing so will allow you to customize the arguments that each serializer field is initialized with. Each of these methods may either return a field or serializer instance, or `None`.
diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md
index 96d715ea..0aa4b6a9 100644
--- a/docs/api-guide/settings.md
+++ b/docs/api-guide/settings.md
@@ -1,4 +1,4 @@
-
+source: settings.py
# Settings
diff --git a/docs/api-guide/status-codes.md b/docs/api-guide/status-codes.md
index 64c46434..d81e092c 100644
--- a/docs/api-guide/status-codes.md
+++ b/docs/api-guide/status-codes.md
@@ -1,4 +1,4 @@
-
+source: status.py
# Status Codes
@@ -27,7 +27,7 @@ The module also includes a set of helper functions for testing if a status code
url = reverse('index')
response = self.client.get(url)
self.assertTrue(status.is_success(response.status_code))
-
+
For more information on proper usage of HTTP status codes see [RFC 2616][rfc2616]
and [RFC 6585][rfc6585].
@@ -51,7 +51,7 @@ This class of status code indicates that the client's request was successfully r
HTTP_205_RESET_CONTENT
HTTP_206_PARTIAL_CONTENT
-## Redirection - 3xx
+## Redirection - 3xx
This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.
diff --git a/docs/api-guide/testing.md b/docs/api-guide/testing.md
index 72c33961..d059fdab 100644
--- a/docs/api-guide/testing.md
+++ b/docs/api-guide/testing.md
@@ -1,4 +1,4 @@
-
+source: test.py
# Testing
@@ -170,7 +170,7 @@ This can be a useful shortcut if you're testing the API but don't want to have t
To unauthenticate subsequent requests, call `force_authenticate` setting the user and/or token to `None`.
- client.force_authenticate(user=None)
+ client.force_authenticate(user=None)
## CSRF validation
@@ -197,7 +197,7 @@ You can use any of REST framework's test case classes as you would for the regul
from django.core.urlresolvers import reverse
from rest_framework import status
- from rest_framework.test import APITestCase
+ from rest_framework.test import APITestCase
class AccountTests(APITestCase):
def test_create_account(self):
diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md
index 147c16ff..3f668867 100644
--- a/docs/api-guide/throttling.md
+++ b/docs/api-guide/throttling.md
@@ -1,4 +1,4 @@
-
+source: throttling.py
# Throttling
@@ -83,7 +83,7 @@ The throttle classes provided by REST framework use Django's cache backend. You
If you need to use a cache other than `'default'`, you can do so by creating a custom throttle class and setting the `cache` attribute. For example:
class CustomAnonRateThrottle(AnonRateThrottle):
- cache = get_cache('alternate')
+ cache = get_cache('alternate')
You'll need to remember to also set your custom throttle class in the `'DEFAULT_THROTTLE_CLASSES'` settings key, or using the `throttle_classes` view attribute.
@@ -147,15 +147,15 @@ For example, given the following views...
class ContactListView(APIView):
throttle_scope = 'contacts'
...
-
+
class ContactDetailView(ApiView):
throttle_scope = 'contacts'
...
- class UploadView(APIView):
+ class UploadView(APIView):
throttle_scope = 'uploads'
...
-
+
...and the following settings.
REST_FRAMEWORK = {
diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md
index 194a7a6b..31c62682 100644
--- a/docs/api-guide/views.md
+++ b/docs/api-guide/views.md
@@ -1,4 +1,5 @@
-
+source: decorators.py
+ views.py
# Class Based Views
@@ -26,7 +27,7 @@ For example:
class ListUsers(APIView):
"""
View to list all users in the system.
-
+
* Requires token authentication.
* Only admin users are able to access this view.
"""
@@ -54,7 +55,7 @@ The following attributes control the pluggable aspects of API views.
### .permission_classes
-### .content_negotiation_class
+### .content_negotiation_class
## API policy instantiation methods
diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md
index 9030e3ee..9249d875 100644
--- a/docs/api-guide/viewsets.md
+++ b/docs/api-guide/viewsets.md
@@ -1,4 +1,4 @@
-
+source: viewsets.py
# ViewSets
diff --git a/docs/theme/content.html b/docs/theme/content.html
new file mode 100644
index 00000000..93a437ff
--- /dev/null
+++ b/docs/theme/content.html
@@ -0,0 +1,11 @@
+{% if meta.source %}
+
+ {% for filename in meta.source %}
+
+ {{ filename }}
+
+ {% endfor %}
+
+{% endif %}
+
+{{ content }}
diff --git a/docs_theme/base.html b/docs_theme/base.html
index 4ca6cd81..07582392 100644
--- a/docs_theme/base.html
+++ b/docs_theme/base.html
@@ -118,7 +118,7 @@ a.fusion-poweredby {
- {% endfor %}
- {% endfor %}
-
- {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
- {% if current_page.input_path == 'index.md' %}
-
+ {% endfor %} {% endfor %} {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #} {% if current_page.input_path == 'index.md' %}
+
--
cgit v1.2.3
From 06683b86b2b15153df52fe481b5c4eeb489a80cf Mon Sep 17 00:00:00 2001
From: José Padilla
Date: Fri, 31 Oct 2014 13:02:11 -0400
Subject: Use single quotes for consistency
Conflicts:
mkdocs.yml
---
mkdocs.yml | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/mkdocs.yml b/mkdocs.yml
index 2d1886a0..c70de982 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -13,30 +13,30 @@ pages:
- ['tutorial/4-authentication-and-permissions.md', ]
- ['tutorial/5-relationships-and-hyperlinked-apis.md', ]
- ['tutorial/6-viewsets-and-routers.md', ]
- - ['api-guide/requests.md', "API Guide", ]
- - ['api-guide/responses.md', "API Guide", ]
- - ['api-guide/views.md', "API Guide", ]
- - ['api-guide/generic-views.md', "API Guide", ]
- - ['api-guide/viewsets.md', "API Guide", ]
- - ['api-guide/routers.md', "API Guide", ]
- - ['api-guide/parsers.md', "API Guide", ]
- - ['api-guide/renderers.md', "API Guide", ]
- - ['api-guide/serializers.md', "API Guide", ]
- - ['api-guide/fields.md', "API Guide", ]
- - ['api-guide/relations.md', "API Guide", ]
- - ['api-guide/validators.md', "API Guide", ]
- - ['api-guide/authentication.md', "API Guide", ]
- - ['api-guide/permissions.md', "API Guide", ]
- - ['api-guide/throttling.md', "API Guide", ]
- - ['api-guide/filtering.md', "API Guide", ]
- - ['api-guide/pagination.md', "API Guide", ]
- - ['api-guide/content-negotiation.md', "API Guide", ]
- - ['api-guide/format-suffixes.md', "API Guide", ]
- - ['api-guide/reverse.md', "API Guide", ]
- - ['api-guide/exceptions.md', "API Guide", ]
- - ['api-guide/status-codes.md', "API Guide", ]
- - ['api-guide/testing.md', "API Guide", ]
- - ['api-guide/settings.md', "API Guide", ]
+ - ['api-guide/requests.md', 'API Guide', ]
+ - ['api-guide/responses.md', 'API Guide', ]
+ - ['api-guide/views.md', 'API Guide', ]
+ - ['api-guide/generic-views.md', 'API Guide', ]
+ - ['api-guide/viewsets.md', 'API Guide', ]
+ - ['api-guide/routers.md', 'API Guide', ]
+ - ['api-guide/parsers.md', 'API Guide', ]
+ - ['api-guide/renderers.md', 'API Guide', ]
+ - ['api-guide/serializers.md', 'API Guide', ]
+ - ['api-guide/fields.md', 'API Guide', ]
+ - ['api-guide/relations.md', 'API Guide', ]
+ - ['api-guide/validators.md', 'API Guide', ]
+ - ['api-guide/authentication.md', 'API Guide', ]
+ - ['api-guide/permissions.md', 'API Guide', ]
+ - ['api-guide/throttling.md', 'API Guide', ]
+ - ['api-guide/filtering.md', 'API Guide', ]
+ - ['api-guide/pagination.md', 'API Guide', ]
+ - ['api-guide/content-negotiation.md', 'API Guide', ]
+ - ['api-guide/format-suffixes.md', 'API Guide', ]
+ - ['api-guide/reverse.md', 'API Guide', ]
+ - ['api-guide/exceptions.md', 'API Guide', ]
+ - ['api-guide/status-codes.md', 'API Guide', ]
+ - ['api-guide/testing.md', 'API Guide', ]
+ - ['api-guide/settings.md', 'API Guide', ]
- ['topics/documenting-your-api.md', ]
- ['topics/ajax-csrf-cors.md', ]
- ['topics/browser-enhancements.md', ]
--
cgit v1.2.3
From 200e0b17daecd07de6d1f9926a430d29b3ee948f Mon Sep 17 00:00:00 2001
From: José Padilla
Date: Fri, 31 Oct 2014 13:03:39 -0400
Subject: Clean up extra white space
---
docs/topics/2.2-announcement.md | 8 ++++----
docs/topics/2.3-announcement.md | 8 ++++----
docs/topics/documenting-your-api.md | 8 ++++----
docs/topics/kickstarter-announcement.md | 2 +-
docs/topics/release-notes.md | 2 +-
docs/topics/rest-framework-2-announcement.md | 4 ++--
docs/topics/writable-nested-serializers.md | 10 +++++-----
docs/tutorial/1-serialization.md | 2 +-
8 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/docs/topics/2.2-announcement.md b/docs/topics/2.2-announcement.md
index a997c782..1df52cff 100644
--- a/docs/topics/2.2-announcement.md
+++ b/docs/topics/2.2-announcement.md
@@ -42,7 +42,7 @@ The 2.2 release makes a few changes to the API, in order to make it more consist
The `ManyRelatedField()` style is being deprecated in favor of a new `RelatedField(many=True)` syntax.
-For example, if a user is associated with multiple questions, which we want to represent using a primary key relationship, we might use something like the following:
+For example, if a user is associated with multiple questions, which we want to represent using a primary key relationship, we might use something like the following:
class UserSerializer(serializers.HyperlinkedModelSerializer):
questions = serializers.PrimaryKeyRelatedField(many=True)
@@ -58,10 +58,10 @@ The change also applies to serializers. If you have a nested serializer, you sh
class Meta:
model = Track
fields = ('name', 'duration')
-
+
class AlbumSerializer(serializer.ModelSerializer):
tracks = TrackSerializer(many=True)
-
+
class Meta:
model = Album
fields = ('album_name', 'artist', 'tracks')
@@ -87,7 +87,7 @@ For example, is a user account has an optional foreign key to a company, that yo
This is in line both with the rest of the serializer fields API, and with Django's `Form` and `ModelForm` API.
-Using `required` throughout the serializers API means you won't need to consider if a particular field should take `blank` or `null` arguments instead of `required`, and also means there will be more consistent behavior for how fields are treated when they are not present in the incoming data.
+Using `required` throughout the serializers API means you won't need to consider if a particular field should take `blank` or `null` arguments instead of `required`, and also means there will be more consistent behavior for how fields are treated when they are not present in the incoming data.
The `null=True` argument will continue to function, and will imply `required=False`, but will raise a `PendingDeprecationWarning`.
diff --git a/docs/topics/2.3-announcement.md b/docs/topics/2.3-announcement.md
index 7c800afa..9c9f3e9f 100644
--- a/docs/topics/2.3-announcement.md
+++ b/docs/topics/2.3-announcement.md
@@ -27,7 +27,7 @@ As an example of just how simple REST framework APIs can now be, here's an API w
class GroupViewSet(viewsets.ModelViewSet):
model = Group
-
+
# Routers provide an easy way of automatically determining the URL conf
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
@@ -197,13 +197,13 @@ Usage of the old-style attributes continues to be supported, but will raise a `P
For most cases APIs using model fields will behave as previously, however if you are using a custom renderer, not provided by REST framework, then you may now need to add support for rendering `Decimal` instances to your renderer implementation.
-## ModelSerializers and reverse relationships
+## ModelSerializers and reverse relationships
The support for adding reverse relationships to the `fields` option on a `ModelSerializer` class means that the `get_related_field` and `get_nested_field` method signatures have now changed.
In the unlikely event that you're providing a custom serializer class, and implementing these methods you should note the new call signature for both methods is now `(self, model_field, related_model, to_many)`. For reverse relationships `model_field` will be `None`.
-The old-style signature will continue to function but will raise a `PendingDeprecationWarning`.
+The old-style signature will continue to function but will raise a `PendingDeprecationWarning`.
## View names and descriptions
@@ -211,7 +211,7 @@ The mechanics of how the names and descriptions used in the browseable API are g
If you've been customizing this behavior, for example perhaps to use `rst` markup for the browseable API, then you'll need to take a look at the implementation to see what updates you need to make.
-Note that the relevant methods have always been private APIs, and the docstrings called them out as intended to be deprecated.
+Note that the relevant methods have always been private APIs, and the docstrings called them out as intended to be deprecated.
---
diff --git a/docs/topics/documenting-your-api.md b/docs/topics/documenting-your-api.md
index e20f9712..d65e251f 100644
--- a/docs/topics/documenting-your-api.md
+++ b/docs/topics/documenting-your-api.md
@@ -54,7 +54,7 @@ The title that is used in the browsable API is generated from the view class nam
For example, the view `UserListView`, will be named `User List` when presented in the browsable API.
-When working with viewsets, an appropriate suffix is appended to each generated view. For example, the view set `UserViewSet` will generate views named `User List` and `User Instance`.
+When working with viewsets, an appropriate suffix is appended to each generated view. For example, the view set `UserViewSet` will generate views named `User List` and `User Instance`.
#### Setting the description
@@ -65,9 +65,9 @@ If the python `markdown` library is installed, then [markdown syntax][markdown]
class AccountListView(views.APIView):
"""
Returns a list of all **active** accounts in the system.
-
+
For more details on how accounts are activated please [see here][ref].
-
+
[ref]: http://example.com/activating-accounts
"""
@@ -84,7 +84,7 @@ You can modify the response behavior to `OPTIONS` requests by overriding the `me
def metadata(self, request):
"""
Don't include the view description in OPTIONS responses.
- """
+ """
data = super(ExampleView, self).metadata(request)
data.pop('description')
return data
diff --git a/docs/topics/kickstarter-announcement.md b/docs/topics/kickstarter-announcement.md
index 7d1f6d0e..e8bad95b 100644
--- a/docs/topics/kickstarter-announcement.md
+++ b/docs/topics/kickstarter-announcement.md
@@ -160,4 +160,4 @@ The following individuals made a significant financial contribution to the devel
### Supporters
-There were also almost 300 further individuals choosing to help fund the project at other levels or choosing to give anonymously. Again, thank you, thank you, thank you!
\ No newline at end of file
+There were also almost 300 further individuals choosing to help fund the project at other levels or choosing to give anonymously. Again, thank you, thank you, thank you!
diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md
index 88780c3f..9fca949a 100644
--- a/docs/topics/release-notes.md
+++ b/docs/topics/release-notes.md
@@ -63,7 +63,7 @@ You can determine your currently installed version using `pip freeze`:
* Bugfix: Fix migration in `authtoken` application.
* Bugfix: Allow selection of integer keys in nested choices.
* Bugfix: Return `None` instead of `'None'` in `CharField` with `allow_none=True`.
-* Bugfix: Ensure custom model fields map to equivelent serializer fields more reliably.
+* Bugfix: Ensure custom model fields map to equivelent serializer fields more reliably.
* Bugfix: `DjangoFilterBackend` no longer quietly changes queryset ordering.
### 2.4.2
diff --git a/docs/topics/rest-framework-2-announcement.md b/docs/topics/rest-framework-2-announcement.md
index f1060d90..a7746932 100644
--- a/docs/topics/rest-framework-2-announcement.md
+++ b/docs/topics/rest-framework-2-announcement.md
@@ -8,7 +8,7 @@ What it is, and why you should care.
---
-**Announcement:** REST framework 2 released - Tue 30th Oct 2012
+**Announcement:** REST framework 2 released - Tue 30th Oct 2012
---
@@ -37,7 +37,7 @@ REST framework 2 includes a totally re-worked serialization engine, that was ini
* A declarative serialization API, that mirrors Django's `Forms`/`ModelForms` API.
* Structural concerns are decoupled from encoding concerns.
* Able to support rendering and parsing to many formats, including both machine-readable representations and HTML forms.
-* Validation that can be mapped to obvious and comprehensive error responses.
+* Validation that can be mapped to obvious and comprehensive error responses.
* Serializers that support both nested, flat, and partially-nested representations.
* Relationships that can be expressed as primary keys, hyperlinks, slug fields, and other custom representations.
diff --git a/docs/topics/writable-nested-serializers.md b/docs/topics/writable-nested-serializers.md
index abc6a82f..ed614bd2 100644
--- a/docs/topics/writable-nested-serializers.md
+++ b/docs/topics/writable-nested-serializers.md
@@ -8,7 +8,7 @@ Although flat data structures serve to properly delineate between the individual
Nested data structures are easy enough to work with if they're read-only - simply nest your serializer classes and you're good to go. However, there are a few more subtleties to using writable nested serializers, due to the dependencies between the various model instances, and the need to save or delete multiple instances in a single action.
-## One-to-many data structures
+## One-to-many data structures
*Example of a **read-only** nested serializer. Nothing complex to worry about here.*
@@ -16,10 +16,10 @@ Nested data structures are easy enough to work with if they're read-only - simpl
class Meta:
model = ToDoItem
fields = ('text', 'is_completed')
-
+
class ToDoListSerializer(serializers.ModelSerializer):
items = ToDoItemSerializer(many=True, read_only=True)
-
+
class Meta:
model = ToDoList
fields = ('title', 'items')
@@ -31,7 +31,7 @@ Some example output from our serializer.
'items': {
{'text': 'Compile playlist', 'is_completed': True},
{'text': 'Send invites', 'is_completed': False},
- {'text': 'Clean house', 'is_completed': False}
+ {'text': 'Clean house', 'is_completed': False}
}
}
@@ -44,4 +44,4 @@ Let's take a look at updating our nested one-to-many data structure.
### Making PATCH requests
-[cite]: http://jsonapi.org/format/#url-based-json-api
\ No newline at end of file
+[cite]: http://jsonapi.org/format/#url-based-json-api
diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md
index db5b9ea7..f9027b68 100644
--- a/docs/tutorial/1-serialization.md
+++ b/docs/tutorial/1-serialization.md
@@ -134,7 +134,7 @@ A serializer class is very similar to a Django `Form` class, and includes simila
The field flags can also control how the serializer should be displayed in certain circumstances, such as when rendering to HTML. The `style={'type': 'textarea'}` flag above is equivelent to using `widget=widgets.Textarea` on a Django `Form` class. This is particularly useful for controlling how the browsable API should be displayed, as we'll see later in the tutorial.
-We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit.
+We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit.
## Working with Serializers
--
cgit v1.2.3
From b8aa7e0c34dc839a47b679aa2402d0f1b98704a0 Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Tue, 18 Nov 2014 17:16:54 +0000
Subject: Fix previous and next links
---
docs_theme/nav.html | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/docs_theme/nav.html b/docs_theme/nav.html
index 87e197b3..0f3b9871 100644
--- a/docs_theme/nav.html
+++ b/docs_theme/nav.html
@@ -2,8 +2,12 @@
- {% endfor %} {% endfor %} {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #} {% if current_page.input_path == 'index.md' %}
+
+
+ {% endfor %}
+
+ {% endfor %}
+
+ {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
+ {% if current_page.input_path == 'index.md' %}
--
cgit v1.2.3
From deb2bb4376600187c881f91791c278d9486ea8d9 Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Wed, 19 Nov 2014 16:15:47 +0000
Subject: Add Home link to the theme
---
docs_theme/nav.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs_theme/nav.html b/docs_theme/nav.html
index e6ab01ba..622cb33b 100644
--- a/docs_theme/nav.html
+++ b/docs_theme/nav.html
@@ -19,6 +19,7 @@
{% if include_nav %}
{% for nav_item in nav %} {% if nav_item.children %}
{{ nav_item.title }}
--
cgit v1.2.3
From aa1a844154e96719c9a91f604286eb0f436f32ea Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Tue, 25 Nov 2014 13:05:48 +0000
Subject: Add The title to the top of the TOC for the home page
---
docs_theme/base.html | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/docs_theme/base.html b/docs_theme/base.html
index 02be73ee..228b0ba4 100644
--- a/docs_theme/base.html
+++ b/docs_theme/base.html
@@ -105,6 +105,13 @@
-->
+
+ {% if current_page.input_path == 'index.md' %}
+
--
cgit v1.2.3
From 4d28a0930995a3a73860d6a2d405e12abbf5d653 Mon Sep 17 00:00:00 2001
From: Dougal Matthews
Date: Tue, 25 Nov 2014 13:09:47 +0000
Subject: Refer to the current_page title rather than filename
---
docs_theme/base.html | 11 ++++-------
docs_theme/nav.html | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/docs_theme/base.html b/docs_theme/base.html
index 004fbacd..cefaef48 100644
--- a/docs_theme/base.html
+++ b/docs_theme/base.html
@@ -54,9 +54,7 @@
}
-{# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
-
-
+
@@ -106,7 +104,7 @@
- {% if current_page.input_path == 'index.md' %}
+ {% if current_page.title == 'Home' %}
@@ -126,8 +124,7 @@
{% endfor %}
- {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #}
- {% if current_page.input_path == 'index.md' %}
+ {% if current_page.title == 'Home' %}
diff --git a/docs_theme/nav.html b/docs_theme/nav.html
index 84982ff3..24304b8a 100644
--- a/docs_theme/nav.html
+++ b/docs_theme/nav.html
@@ -19,7 +19,7 @@
{% if include_nav %}