From d365621cbeb333d857dd312147edd5cd076866e8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 9 Nov 2012 16:44:39 +0000 Subject: Note django-filter installation --- docs/index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/index.md b/docs/index.md index 1874ec00..fd834540 100644 --- a/docs/index.md +++ b/docs/index.md @@ -32,7 +32,7 @@ REST framework requires the following: The following packages are optional: -* [Markdown][markdown] (2.1.0+) - Markdown support for the self describing API. +* [Markdown][markdown] (2.1.0+) - Markdown support for the browseable API. * [PyYAML][yaml] (3.10+) - YAML content-type support. * [django-filter][django-filter] (master) - Filtering support. @@ -41,8 +41,9 @@ The following packages are optional: Install using `pip`, including any optional packages you want... pip install djangorestframework - pip install markdown # Recommended if using the browseable API. - pip install pyyaml # Required for yaml content-type support. + pip install markdown # Markdown support for the browseable API. + pip install pyyaml # YAML content-type support. + pip install -e git+https://github.com/alex/django-filter.git#egg=django-filter # Filtering support ...or clone the project from github. -- cgit v1.2.3 From e224061189a6a5ea2c063f3820239eed6c3a88fb Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 9 Nov 2012 17:01:20 +0000 Subject: Support for `read_only_fields` on `ModelSerializer` classes --- docs/api-guide/serializers.md | 9 +++++++++ docs/topics/release-notes.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 0cdae1ce..a9589144 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -248,6 +248,15 @@ The default `ModelSerializer` uses primary keys for relationships, but you can a The `depth` option should be set to an integer value that indicates the depth of relationships that should be traversed before reverting to a flat representation. +## Specifying which fields should be read-only + +You may wish to specify multiple fields as read-only. Instead of adding each field explicitely with the `read_only=True` attribute, you may use the `read_only_fields` Meta option, like so: + + class AccountSerializer(serializers.ModelSerializer): + class Meta: + model = Account + read_only_fields = ('created', 'modified') + ## Customising the default fields You can create customized subclasses of `ModelSerializer` that use a different set of default fields for the representation, by overriding various `get__field` methods. diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 670332e6..35e8a8b3 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,10 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## Master + +* Support for `read_only_fields` on `ModelSerializer` classes. + ## 2.1.2 **Date**: 9th Nov 2012 -- cgit v1.2.3 From ffb4fe66ceb20404cd821811e642fce878bbf4d1 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 10 Nov 2012 17:03:08 +0000 Subject: Added @glic3rinu. Thanks! --- docs/topics/credits.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 1a2c0db8..3fe4357e 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -58,7 +58,7 @@ The following people have helped make REST framework great. * Michael Shepanski - [mjs7231] * Toni Michel - [tonimichel] * Ben Konrath - [benkonrath] - +* Marc Aymerich - [glic3rinu] Many thanks to everyone who's contributed to the project. ## Additional thanks @@ -151,3 +151,4 @@ To contact the author directly: [mjs7231]: https://github.com/mjs7231 [tonimichel]: https://github.com/tonimichel [benkonrath]: https://github.com/benkonrath +[glic3rinu]: https://github.com/glic3rinu -- cgit v1.2.3 From f9a9ff1db08f5ed8c765569fb936b21d5c6def6c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 10 Nov 2012 17:04:31 +0000 Subject: Newline --- docs/topics/credits.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 3fe4357e..22d08df7 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -59,6 +59,7 @@ The following people have helped make REST framework great. * Toni Michel - [tonimichel] * Ben Konrath - [benkonrath] * Marc Aymerich - [glic3rinu] + Many thanks to everyone who's contributed to the project. ## Additional thanks -- cgit v1.2.3 From d3ee5080a0ff3894050442146083f9d4a2327c8f Mon Sep 17 00:00:00 2001 From: Rob Romano Date: Tue, 13 Nov 2012 15:03:42 -0800 Subject: Added documentation on how to use the token authentication login view. --- docs/api-guide/authentication.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 3137b9d4..50d8c054 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -97,6 +97,22 @@ If successfully authenticated, `TokenAuthentication` provides the following cred **Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https` only. +When using TokenAuthentication, it may be useful to add a login view for clients to retrieve the token. + +REST framework provides a built-in login view. To use it, add a pattern to include the token login view for clients as follows: + + urlpatterns += patterns('', + url(r'^api-token-auth/', include('rest_framework.authtoken.urls', + namespace='rest_framework')) + ) + +The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The only restriction is that the included urls must use the `'rest_framework'` namespace. + +The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: + + { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } + + ## OAuthAuthentication This policy uses the [OAuth 2.0][oauth] protocol to authenticate requests. OAuth is appropriate for server-server setups, such as when you want to allow a third-party service to access your API on a user's behalf. -- cgit v1.2.3 From 4fd590f96f77eae433f1d5de281ed95f5a003745 Mon Sep 17 00:00:00 2001 From: Rob Romano Date: Tue, 13 Nov 2012 16:49:13 -0800 Subject: Renamed AuthTokenView to ObtainAuthToken, added obtain_auth_token var, updated tests & docs. Left authtoken.urls in place as example. --- docs/api-guide/authentication.md | 14 ++++---------- docs/topics/credits.md | 2 ++ docs/topics/release-notes.md | 1 + 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 50d8c054..18620f49 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -97,21 +97,15 @@ If successfully authenticated, `TokenAuthentication` provides the following cred **Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https` only. -When using TokenAuthentication, it may be useful to add a login view for clients to retrieve the token. - -REST framework provides a built-in login view. To use it, add a pattern to include the token login view for clients as follows: +REST framework provides a built-in login view for clients to retrieve the token called `rest_framework.authtoken.obtain_auth_token`. To use it, add a pattern to include the token login view for clients as follows: urlpatterns += patterns('', - url(r'^api-token-auth/', include('rest_framework.authtoken.urls', - namespace='rest_framework')) + url(r'^api-token-auth/', 'rest_framework.authtoken.obtain_auth_token') ) -The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The only restriction is that the included urls must use the `'rest_framework'` namespace. - -The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: - - { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } +The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: + { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } ## OAuthAuthentication diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 22d08df7..f378a521 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -59,6 +59,7 @@ The following people have helped make REST framework great. * Toni Michel - [tonimichel] * Ben Konrath - [benkonrath] * Marc Aymerich - [glic3rinu] +* Rob Romano - [robromano] Many thanks to everyone who's contributed to the project. @@ -153,3 +154,4 @@ To contact the author directly: [tonimichel]: https://github.com/tonimichel [benkonrath]: https://github.com/benkonrath [glic3rinu]: https://github.com/glic3rinu +[robromano]: https://github.com/robromano diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 35e8a8b3..daacc76f 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,6 +7,7 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. +* Add convenience login view to get tokens when using `TokenAuthentication` ## 2.1.2 -- cgit v1.2.3 From 8b999c6bb500a045c6c32412009cbd3b1cd5a56b Mon Sep 17 00:00:00 2001 From: Ludwig Kraatz Date: Wed, 14 Nov 2012 11:46:16 +0100 Subject: polishing code and adding myself to auhtors file --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 22d08df7..8e71c937 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -59,6 +59,7 @@ The following people have helped make REST framework great. * Toni Michel - [tonimichel] * Ben Konrath - [benkonrath] * Marc Aymerich - [glic3rinu] +* Ludwig Kraatz - [ludwigkraatz] Many thanks to everyone who's contributed to the project. @@ -153,3 +154,4 @@ To contact the author directly: [tonimichel]: https://github.com/tonimichel [benkonrath]: https://github.com/benkonrath [glic3rinu]: https://github.com/glic3rinu +[ludwigkraatz]: https://github.com/ludwigkraatz -- cgit v1.2.3 From 33fe0d2bea5ce391a69047236c121ec5b33d9b2f Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 14 Nov 2012 16:08:14 +0100 Subject: added release note --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 35e8a8b3..40ce4352 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,6 +7,7 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. +* Support for `page_size` GET parameter in view which inherit ListModelMixin ## 2.1.2 -- cgit v1.2.3 From 5967f15f7f5c87987ab60e4b7dc682b06f3ab511 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 14 Nov 2012 16:11:35 +0100 Subject: updated docs --- docs/api-guide/generic-views.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 360ef1a2..9e5119cb 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -147,6 +147,10 @@ Provides a `.list(request, *args, **kwargs)` method, that implements listing a q Should be mixed in with [MultipleObjectAPIView]. +**Arguments**: + +* `page_size` - Hook to adjust page_size per request. + ## CreateModelMixin Provides a `.create(request, *args, **kwargs)` method, that implements creating and saving a new model instance. -- cgit v1.2.3 From 1e83b60a43c26db921d6910092362feb3a76500d Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 14 Nov 2012 18:00:59 +0100 Subject: added description how to use the auth token --- docs/api-guide/authentication.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 3137b9d4..cb1e2645 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -97,6 +97,21 @@ If successfully authenticated, `TokenAuthentication` provides the following cred **Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https` only. +If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal. + + @receiver(post_save, sender=User) + def create_auth_token(sender, instance=None, created=False, **kwargs): + if created: + Token.objects.create(user=instance) + +If you've already created some User`'s, you can run a script like this. + + from django.contrib.auth.models import User + from rest_framework.authtoken.models import Token + + for user in User.objects.all(): + Token.objects.get_or_create(user=user) + ## OAuthAuthentication This policy uses the [OAuth 2.0][oauth] protocol to authenticate requests. OAuth is appropriate for server-server setups, such as when you want to allow a third-party service to access your API on a user's behalf. -- cgit v1.2.3 From eb20b5663e68ce01453eeb855922874001f42d0f Mon Sep 17 00:00:00 2001 From: Rob Romano Date: Tue, 13 Nov 2012 15:03:42 -0800 Subject: Added documentation on how to use the token authentication login view. --- docs/api-guide/authentication.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index cb1e2645..a55059a8 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -112,6 +112,21 @@ If you've already created some User`'s, you can run a script like this. for user in User.objects.all(): Token.objects.get_or_create(user=user) +When using TokenAuthentication, it may be useful to add a login view for clients to retrieve the token. + +REST framework provides a built-in login view. To use it, add a pattern to include the token login view for clients as follows: + + urlpatterns += patterns('', + url(r'^api-token-auth/', include('rest_framework.authtoken.urls', + namespace='rest_framework')) + ) + +The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The only restriction is that the included urls must use the `'rest_framework'` namespace. + +The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: + + { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } + ## OAuthAuthentication This policy uses the [OAuth 2.0][oauth] protocol to authenticate requests. OAuth is appropriate for server-server setups, such as when you want to allow a third-party service to access your API on a user's behalf. -- cgit v1.2.3 From 321ba156ca45da8a4b3328c4aec6a9235f32e5f8 Mon Sep 17 00:00:00 2001 From: Rob Romano Date: Tue, 13 Nov 2012 16:49:13 -0800 Subject: Renamed AuthTokenView to ObtainAuthToken, added obtain_auth_token var, updated tests & docs. Left authtoken.urls in place as example. --- docs/api-guide/authentication.md | 11 ++++------- docs/topics/credits.md | 3 +++ docs/topics/release-notes.md | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index a55059a8..a30bd22c 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -114,18 +114,15 @@ If you've already created some User`'s, you can run a script like this. When using TokenAuthentication, it may be useful to add a login view for clients to retrieve the token. -REST framework provides a built-in login view. To use it, add a pattern to include the token login view for clients as follows: +REST framework provides a built-in login view for clients to retrieve the token called `rest_framework.authtoken.obtain_auth_token`. To use it, add a pattern to include the token login view for clients as follows: urlpatterns += patterns('', - url(r'^api-token-auth/', include('rest_framework.authtoken.urls', - namespace='rest_framework')) + url(r'^api-token-auth/', 'rest_framework.authtoken.obtain_auth_token') ) -The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The only restriction is that the included urls must use the `'rest_framework'` namespace. +The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: -The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: - - { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } + { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } ## OAuthAuthentication diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 8e71c937..939dfc57 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -60,6 +60,7 @@ The following people have helped make REST framework great. * Ben Konrath - [benkonrath] * Marc Aymerich - [glic3rinu] * Ludwig Kraatz - [ludwigkraatz] +* Rob Romano - [robromano] Many thanks to everyone who's contributed to the project. @@ -155,3 +156,5 @@ To contact the author directly: [benkonrath]: https://github.com/benkonrath [glic3rinu]: https://github.com/glic3rinu [ludwigkraatz]: https://github.com/ludwigkraatz +[robromano]: https://github.com/robromano + diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 35e8a8b3..daacc76f 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,6 +7,7 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. +* Add convenience login view to get tokens when using `TokenAuthentication` ## 2.1.2 -- cgit v1.2.3 From 38e94bb8b4e04249b18b9b57ef2ddcb7cfc4efa4 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Thu, 15 Nov 2012 11:15:05 +0100 Subject: added global and per resource on/off switch + updated docs --- docs/api-guide/generic-views.md | 3 ++- docs/api-guide/settings.md | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 9e5119cb..734a91e9 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -149,7 +149,8 @@ Should be mixed in with [MultipleObjectAPIView]. **Arguments**: -* `page_size` - Hook to adjust page_size per request. +* `allow_page_size_param` - Allows you to overwrite the global settings `ALLOW_PAGE_SIZE_PARAM` for a specific view. +* `page_size_param` - Allows you to customize the page_size parameter. Default is `page_size`. ## CreateModelMixin diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index 4f87b30d..2f90369b 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -150,4 +150,10 @@ Default: `'accept'` Default: `'format'` +## ALLOW_PAGE_SIZE_PARAM + +Allows you to globally pass a page size parameter for an individual request. + +Default: `'True'` + [cite]: http://www.python.org/dev/peps/pep-0020/ -- cgit v1.2.3 From b17a9818008cf3828adb896ae9be134fb63c5693 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Thu, 15 Nov 2012 11:24:17 +0100 Subject: updated release noted for page_size stuff --- docs/topics/release-notes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 40ce4352..f4a76c89 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,7 +7,9 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. -* Support for `page_size` GET parameter in view which inherit ListModelMixin +* Support for `page_size` GET parameter in views which inherit ListModelMixin. +* Support for customizing `page_size` param via `page_size_param` attribute. +* Support for allowing `page_size` param globally (via `ALLOW_PAGE_SIZE_PARAM`) and for individual views (via `allow_page_size_param`) ## 2.1.2 -- cgit v1.2.3 From 3ae203a0184d27318a8a828ce322b151ade0340f Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Thu, 15 Nov 2012 12:06:43 +0100 Subject: updated script to just use page_size_kwarg --- docs/api-guide/generic-views.md | 3 +-- docs/api-guide/settings.md | 8 ++++++-- docs/topics/release-notes.md | 4 +--- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 734a91e9..3346c70a 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -149,8 +149,7 @@ Should be mixed in with [MultipleObjectAPIView]. **Arguments**: -* `allow_page_size_param` - Allows you to overwrite the global settings `ALLOW_PAGE_SIZE_PARAM` for a specific view. -* `page_size_param` - Allows you to customize the page_size parameter. Default is `page_size`. +* `page_size_kwarg` - Allows you to overwrite the global settings `PAGE_SIZE_KWARG` for a specific view. You can also turn it off for a specific view by setting it to `None`. Default is `page_size`. ## CreateModelMixin diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index 2f90369b..8fce9e4e 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -150,10 +150,14 @@ Default: `'accept'` Default: `'format'` -## ALLOW_PAGE_SIZE_PARAM +## PAGE_SIZE_KWARG Allows you to globally pass a page size parameter for an individual request. -Default: `'True'` +The name of the GET parameter of views which inherit ListModelMixin for requesting data with an individual page size. + +If the value if this setting is `None` the passing a page size is turned off by default. + +Default: `'page_size'` [cite]: http://www.python.org/dev/peps/pep-0020/ diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index f4a76c89..85c19f5b 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,9 +7,7 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. -* Support for `page_size` GET parameter in views which inherit ListModelMixin. -* Support for customizing `page_size` param via `page_size_param` attribute. -* Support for allowing `page_size` param globally (via `ALLOW_PAGE_SIZE_PARAM`) and for individual views (via `allow_page_size_param`) +* Support for individual page sizes per request via `page_size` GET parameter in views which inherit ListModelMixin. ## 2.1.2 -- cgit v1.2.3 From b4cfb46a56c8f7d9bc4340d5443f3a2d57ba9b58 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Fri, 16 Nov 2012 00:22:08 +0100 Subject: WIP on docs for File- and ImageFileds. --- docs/api-guide/fields.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 0485b158..0b25a6ef 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -165,6 +165,38 @@ A floating point representation. Corresponds to `django.db.models.fields.FloatField`. +## FileField + +A file representation. Performs Django's standard FileField validation. + +Corresponds to `django.forms.fields.FileField`. + +### Optional arguments + +#### `max_length` + +Maximum length for the file name. This value is obtained from the model when used with a ModelSerializer. + +Defaults to `None`, meaning validation is skipped. + +#### `allow_empty_file` + +Determines if empty file uploads are allowed. + +Defaults to `False` + +## ImageField + +An image representation. + +Corresponds to `django.forms.fields.ImageField`. + +### Optional arguments + +Same as FileField. + +Requires the `PIL` package. + --- # Relational Fields -- cgit v1.2.3 From c5765641a44ad2fb3b80f63f9a47e0dd7f432c94 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 17:28:08 +0000 Subject: Fix typo --- docs/api-guide/filtering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index 14ab9a26..95d9d526 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -71,7 +71,7 @@ We can override `.get_queryset()` to deal with URLs such as `http://example.com/ by filtering against a `username` query parameter in the URL. """ queryset = Purchase.objects.all() - username = self.request.QUERY_PARAMS.get('username', None): + username = self.request.QUERY_PARAMS.get('username', None) if username is not None: queryset = queryset.filter(purchaser__username=username) return queryset -- cgit v1.2.3 From 2f2bde69e42825ad55318e5a5745ee9655b3f81b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 20:58:49 +0000 Subject: Docs, tox and travis use django-filter 0.5.4 --- docs/api-guide/filtering.md | 5 ++--- docs/index.md | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index 95d9d526..53ea7cbc 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -84,9 +84,9 @@ As well as being able to override the default queryset, REST framework also incl REST framework supports pluggable backends to implement filtering, and provides an implementation which uses the [django-filter] package. -To use REST framework's default filtering backend, first install `django-filter`. +To use REST framework's filtering backend, first install `django-filter`. - pip install -e git+https://github.com/alex/django-filter.git#egg=django-filter + pip install django-filter You must also set the filter backend to `DjangoFilterBackend` in your settings: @@ -94,7 +94,6 @@ You must also set the filter backend to `DjangoFilterBackend` in your settings: 'FILTER_BACKEND': 'rest_framework.filters.DjangoFilterBackend' } -**Note**: The currently supported version of `django-filter` is the `master` branch. A PyPI release is expected to be coming soon. ## Specifying filter fields diff --git a/docs/index.md b/docs/index.md index fd834540..cc0f2a13 100644 --- a/docs/index.md +++ b/docs/index.md @@ -34,7 +34,7 @@ The following packages are optional: * [Markdown][markdown] (2.1.0+) - Markdown support for the browseable API. * [PyYAML][yaml] (3.10+) - YAML content-type support. -* [django-filter][django-filter] (master) - Filtering support. +* [django-filter][django-filter] (0.5.4+) - Filtering support. ## Installation @@ -43,7 +43,7 @@ Install using `pip`, including any optional packages you want... pip install djangorestframework pip install markdown # Markdown support for the browseable API. pip install pyyaml # YAML content-type support. - pip install -e git+https://github.com/alex/django-filter.git#egg=django-filter # Filtering support + pip install django-filter # Filtering support ...or clone the project from github. -- cgit v1.2.3 From 0076e2f462402dbb7bd7b3a446d2c397e6bf8d81 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Fri, 16 Nov 2012 23:23:34 +0100 Subject: Added brief docs for URLField and SlugField. --- docs/api-guide/fields.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 0485b158..5977cae2 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -131,6 +131,18 @@ or `django.db.models.fields.TextField`. **Signature:** `CharField(max_length=None, min_length=None)` +## URLField + +Corresponds to `django.db.models.fields.URLField`. Uses Django's `django.core.validators.URLValidator` for validation. + +**Signature:** `CharField(max_length=200, min_length=None)` + +## SlugField + +Corresponds to `django.db.models.fields.SlugField`. + +**Signature:** `CharField(max_length=50, min_length=None)` + ## ChoiceField A field that can accept a value out of a limited set of choices. -- cgit v1.2.3 From f801e5d3050591403de04fde7d18522fabc8fe49 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Fri, 16 Nov 2012 23:44:55 +0100 Subject: Simplified docs a bit for FileField and ImageField. Added note about MultipartParser only supporting file uploads and Django's default upload handlers. --- docs/api-guide/fields.md | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 0b25a6ef..7f42dc5e 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -171,19 +171,11 @@ A file representation. Performs Django's standard FileField validation. Corresponds to `django.forms.fields.FileField`. -### Optional arguments +**Signature:** `FileField(max_length=None, allow_empty_file=False)` -#### `max_length` - -Maximum length for the file name. This value is obtained from the model when used with a ModelSerializer. - -Defaults to `None`, meaning validation is skipped. - -#### `allow_empty_file` - -Determines if empty file uploads are allowed. - -Defaults to `False` + - `max_length` designates the maximum length for the file name. + + - `allow_empty_file` designates if empty files are allowed. ## ImageField @@ -191,11 +183,14 @@ An image representation. Corresponds to `django.forms.fields.ImageField`. -### Optional arguments +Requires the `PIL` package. -Same as FileField. +Signature and validation is the same as with `FileField`. -Requires the `PIL` package. +--- + +**Note:** `FileFields` and `ImageFields` are only suitable for use with MultiPartParser, since eg json doesn't support file uploads. +Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files. --- @@ -318,3 +313,4 @@ This field is always read-only. * `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. [cite]: http://www.python.org/dev/peps/pep-0020/ +[FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS -- cgit v1.2.3 From 31f01bd6315f46bf28bb4c9c25a5298785fc4fc6 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 22:45:57 +0000 Subject: Polishing to page size query parameters & more docs --- docs/api-guide/generic-views.md | 22 ++++++++++++++++++---- docs/api-guide/settings.md | 26 ++++++++++++++++---------- docs/topics/release-notes.md | 3 ++- 3 files changed, 36 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 3346c70a..33ec89d2 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -123,18 +123,36 @@ Each of the generic views provided is built by combining one of the base views b Extends REST framework's `APIView` class, adding support for serialization of model instances and model querysets. +**Attributes**: + +* `model` - The model that should be used for this view. Used as a fallback for determining the serializer if `serializer_class` is not set, and as a fallback for determining the queryset if `queryset` is not set. Otherwise not required. +* `serializer_class` - The serializer class that should be used for validating and deserializing input, and for serializing output. If unset, this defaults to creating a serializer class using `self.model`, with the `DEFAULT_MODEL_SERIALIZER_CLASS` setting as the base serializer class. + ## MultipleObjectAPIView Provides a base view for acting on a single object, by combining REST framework's `APIView`, and Django's [MultipleObjectMixin]. **See also:** ccbv.co.uk documentation for [MultipleObjectMixin][multiple-object-mixin-classy]. +**Attributes**: + +* `queryset` - The queryset that should be used for returning objects from this view. If unset, defaults to the default queryset manager for `self.model`. +* `paginate_by` - The size of pages to use with paginated data. If set to `None` then pagination is turned off. If unset this uses the same value as the `PAGINATE_BY` setting, which defaults to `None`. +* `paginate_by_param` - The name of a query parameter, which can be used by the client to overide the default page size to use for pagination. If unset this uses the same value as the `PAGINATE_BY_PARAM` setting, which defaults to `None`. + ## SingleObjectAPIView Provides a base view for acting on a single object, by combining REST framework's `APIView`, and Django's [SingleObjectMixin]. **See also:** ccbv.co.uk documentation for [SingleObjectMixin][single-object-mixin-classy]. +**Attributes**: + +* `queryset` - The queryset that should be used when retrieving an object from this view. If unset, defaults to the default queryset manager for `self.model`. +* `pk_kwarg` - The URL kwarg that should be used to look up objects by primary key. Defaults to `'pk'`. [Can only be set to non-default on Django 1.4+] +* `slug_kwarg` - The URL kwarg that should be used to look up objects by a slug. Defaults to `'slug'`. [Can only be set to non-default on Django 1.4+] +* `slug_field` - The field on the model that should be used to look up objects by a slug. If used, this should typically be set to a field with `unique=True`. Defaults to `'slug'`. + --- # Mixins @@ -147,10 +165,6 @@ Provides a `.list(request, *args, **kwargs)` method, that implements listing a q Should be mixed in with [MultipleObjectAPIView]. -**Arguments**: - -* `page_size_kwarg` - Allows you to overwrite the global settings `PAGE_SIZE_KWARG` for a specific view. You can also turn it off for a specific view by setting it to `None`. Default is `page_size`. - ## CreateModelMixin Provides a `.create(request, *args, **kwargs)` method, that implements creating and saving a new model instance. diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index 8fce9e4e..7884d096 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -96,11 +96,21 @@ Default: `rest_framework.serializers.ModelSerializer` Default: `rest_framework.pagination.PaginationSerializer` -## FORMAT_SUFFIX_KWARG +## FILTER_BACKEND -**TODO** +The filter backend class that should be used for generic filtering. If set to `None` then generic filtering is disabled. -Default: `'format'` +## PAGINATE_BY + +The default page size to use for pagination. If set to `None`, pagination is disabled by default. + +Default: `None` + +## PAGINATE_BY_KWARG + +The name of a query parameter, which can be used by the client to overide the default page size to use for pagination. If set to `None`, clients may not override the default page size. + +Default: `None` ## UNAUTHENTICATED_USER @@ -150,14 +160,10 @@ Default: `'accept'` Default: `'format'` -## PAGE_SIZE_KWARG - -Allows you to globally pass a page size parameter for an individual request. - -The name of the GET parameter of views which inherit ListModelMixin for requesting data with an individual page size. +## FORMAT_SUFFIX_KWARG -If the value if this setting is `None` the passing a page size is turned off by default. +**TODO** -Default: `'page_size'` +Default: `'format'` [cite]: http://www.python.org/dev/peps/pep-0020/ diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 85c19f5b..869cabc8 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,7 +7,8 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. -* Support for individual page sizes per request via `page_size` GET parameter in views which inherit ListModelMixin. +* Support for clients overriding the pagination page sizes. Use the `PAGINATE_BY_PARAM` setting or set the `paginate_by_param` attribute on a generic view. +* 201 Responses now return a 'Location' header. ## 2.1.2 -- cgit v1.2.3 From 19b0516bfefe3398683b4f878774e3dd80bf653a Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 22:49:15 +0000 Subject: Getting 2.1.3 release notes ready --- docs/topics/release-notes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 869cabc8..5931a75a 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,7 +4,9 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. -## Master +## 2.1.3 + +**Date**: 16th Nov 2012 * Support for `read_only_fields` on `ModelSerializer` classes. * Support for clients overriding the pagination page sizes. Use the `PAGINATE_BY_PARAM` setting or set the `paginate_by_param` attribute on a generic view. -- cgit v1.2.3 From 016ef5019ff43808540f948d674e8dd33247cb99 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 22:58:17 +0000 Subject: Version 2.1.3 --- docs/topics/release-notes.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 5931a75a..2a6fbe83 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -8,9 +8,12 @@ **Date**: 16th Nov 2012 +* Added `FileField` and `ImageField`. For use with `MultiPartParser`. +* Added `URLField` and `SlugField`. * Support for `read_only_fields` on `ModelSerializer` classes. * Support for clients overriding the pagination page sizes. Use the `PAGINATE_BY_PARAM` setting or set the `paginate_by_param` attribute on a generic view. * 201 Responses now return a 'Location' header. +* Bugfix: Serializer fields now respect `max_length`. ## 2.1.2 -- cgit v1.2.3 From 0eba278e1391604086dab1dfa1bd6ea86fea282e Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 23:22:23 +0000 Subject: Improve pagination docs --- docs/api-guide/pagination.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index 597baba4..39e6a32d 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -80,23 +80,21 @@ We could now use our pagination serializer in a view like this. ## Pagination in the generic views -The generic class based views `ListAPIView` and `ListCreateAPIView` provide pagination of the returned querysets by default. You can customise this behaviour by altering the pagination style, by modifying the default number of results, or by turning pagination off completely. +The generic class based views `ListAPIView` and `ListCreateAPIView` provide pagination of the returned querysets by default. You can customise this behaviour by altering the pagination style, by modifying the default number of results, by allowing clients to override the page size using a query parameter, or by turning pagination off completely. -The default pagination style may be set globally, using the `PAGINATION_SERIALIZER` and `PAGINATE_BY` settings. For example. +The default pagination style may be set globally, using the `DEFAULT_PAGINATION_SERIALIZER_CLASS`, `PAGINATE_BY` and `PAGINATE_BY_PARAM` settings. For example. REST_FRAMEWORK = { - 'PAGINATION_SERIALIZER': ( - 'example_app.pagination.CustomPaginationSerializer', - ), - 'PAGINATE_BY': 10 + 'PAGINATE_BY': 10, + 'PAGINATE_BY_PARAM': 'page_size' } You can also set the pagination style on a per-view basis, using the `ListAPIView` generic class-based view. class PaginatedListView(ListAPIView): model = ExampleModel - pagination_serializer_class = CustomPaginationSerializer paginate_by = 10 + paginate_by_param = 'page_size' For more complex requirements such as serialization that differs depending on the requested media type you can override the `.get_paginate_by()` and `.get_pagination_serializer_class()` methods. @@ -122,4 +120,20 @@ For example, to nest a pair of links labelled 'prev' and 'next', and set the nam results_field = 'objects' +## Using your custom pagination serializer + +To have your custom pagination serializer be used by default use the `DEFAULT_PAGINATION_SERIALIZER_CLASS` setting: + + REST_FRAMEWORK = { + 'DEFAULT_PAGINATION_SERIALIZER_CLASS': + 'example_app.pagination.CustomPaginationSerializer', + } + +Alternatively, to set your custom pagination serializer on a per-view basis, use the `pagination_serializer_class` attribute on a generic class based view: + + class PaginatedListView(ListAPIView): + model = ExampleModel + pagination_serializer_class = CustomPaginationSerializer + paginate_by = 10 + [cite]: https://docs.djangoproject.com/en/dev/topics/pagination/ -- cgit v1.2.3 From 2263ed8b9409c709f6dbad2157f8debffb16c1d8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 16 Nov 2012 23:24:36 +0000 Subject: Tweak --- docs/api-guide/pagination.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index 39e6a32d..5a35ed75 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -122,7 +122,7 @@ For example, to nest a pair of links labelled 'prev' and 'next', and set the nam ## Using your custom pagination serializer -To have your custom pagination serializer be used by default use the `DEFAULT_PAGINATION_SERIALIZER_CLASS` setting: +To have your custom pagination serializer be used by default, use the `DEFAULT_PAGINATION_SERIALIZER_CLASS` setting: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_SERIALIZER_CLASS': -- cgit v1.2.3 From 4068323df4a8a8ad8825d5e0ed1d31ee2a36484f Mon Sep 17 00:00:00 2001 From: Eugene MechanisM Date: Sat, 17 Nov 2012 04:03:43 +0400 Subject: Missing import of "Permission" model in docs Missing import of "Permission" model in docs--- docs/tutorial/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/tutorial/quickstart.md b/docs/tutorial/quickstart.md index 93da1a59..9a36a2b0 100644 --- a/docs/tutorial/quickstart.md +++ b/docs/tutorial/quickstart.md @@ -8,7 +8,7 @@ Create a new Django project, and start a new app called `quickstart`. Once you' First up we're going to define some serializers in `quickstart/serializers.py` that we'll use for our data representations. - from django.contrib.auth.models import User, Group + from django.contrib.auth.models import User, Group, Permission from rest_framework import serializers -- cgit v1.2.3 From 346a79b170b0a25fd28354de765c5aa5aca9a119 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 17 Nov 2012 00:29:15 +0000 Subject: Added @MechanisM - Thanks! (That's a mighty kick ass Gravatar)--- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 8e71c937..f037e816 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -60,6 +60,7 @@ The following people have helped make REST framework great. * Ben Konrath - [benkonrath] * Marc Aymerich - [glic3rinu] * Ludwig Kraatz - [ludwigkraatz] +* Eugene Mechanism - [mechanism] Many thanks to everyone who's contributed to the project. @@ -155,3 +156,4 @@ To contact the author directly: [benkonrath]: https://github.com/benkonrath [glic3rinu]: https://github.com/glic3rinu [ludwigkraatz]: https://github.com/ludwigkraatz +[mechanism]: https://github.com/mechanism -- cgit v1.2.3 From f131e533edf58dc8ba7b712b4c3486a3ab053ffc Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sun, 18 Nov 2012 17:57:02 +0000 Subject: Docs, docs, docs, docs, docs, docs --- docs/api-guide/generic-views.md | 18 ++++++++++++++++++ docs/api-guide/pagination.md | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 33ec89d2..428323b8 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -163,30 +163,48 @@ The mixin classes provide the actions that are used to provide the basic view be Provides a `.list(request, *args, **kwargs)` method, that implements listing a queryset. +If the queryset is populated, this returns a `200 OK` response, with a serialized representation of the queryset as the body of the response. The response data may optionally be paginated. + +If the queryset is empty this returns a `200 OK` reponse, unless the `.allow_empty` attribute on the view is set to `False`, in which case it will return a `404 Not Found`. + Should be mixed in with [MultipleObjectAPIView]. ## CreateModelMixin Provides a `.create(request, *args, **kwargs)` method, that implements creating and saving a new model instance. +If an object is created this returns a `201 Created` response, with a serialized representation of the object as the body of the response. If the representation contains a key named `url`, then the `Location` header of the response will be populated with that value. + +If the request data provided for creating the object was invalid, a `400 Bad Request` response will be returned, with the error details as the body of the response. + Should be mixed in with any [GenericAPIView]. ## RetrieveModelMixin Provides a `.retrieve(request, *args, **kwargs)` method, that implements returning an existing model instance in a response. +If an object can be retrieve this returns a `200 OK` response, with a serialized representation of the object as the body of the response. Otherwise it will return a `404 Not Found`. + Should be mixed in with [SingleObjectAPIView]. ## UpdateModelMixin Provides a `.update(request, *args, **kwargs)` method, that implements updating and saving an existing model instance. +If an object is updated this returns a `200 OK` response, with a serialized representation of the object as the body of the response. + +If an object is created, for example when making a `DELETE` request followed by a `PUT` request to the same URL, this returns a `201 Created` response, with a serialized representation of the object as the body of the response. + +If the request data provided for updating the object was invalid, a `400 Bad Request` response will be returned, with the error details as the body of the response. + Should be mixed in with [SingleObjectAPIView]. ## DestroyModelMixin Provides a `.destroy(request, *args, **kwargs)` method, that implements deletion of an existing model instance. +If an object is deleted this returns a `204 No Content` response, otherwise it will return a `404 Not Found`. + Should be mixed in with [SingleObjectAPIView]. [cite]: https://docs.djangoproject.com/en/dev/ref/class-based-views/#base-vs-generic-views diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index 5a35ed75..ab335e6e 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -70,11 +70,12 @@ We could now use our pagination serializer in a view like this. # If page is not an integer, deliver first page. users = paginator.page(1) except EmptyPage: - # If page is out of range (e.g. 9999), deliver last page of results. + # If page is out of range (e.g. 9999), + # deliver last page of results. users = paginator.page(paginator.num_pages) serializer_context = {'request': request} - serializer = PaginatedUserSerializer(instance=users, + serializer = PaginatedUserSerializer(users, context=serializer_context) return Response(serializer.data) -- cgit v1.2.3 From de5b071d677074ab3b6b33a843c4b05ba2052a6b Mon Sep 17 00:00:00 2001 From: Jamie Matthews Date: Mon, 19 Nov 2012 17:22:17 +0000 Subject: Add SerializerMethodField --- docs/api-guide/fields.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index d1c31ecc..b19c324a 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -324,5 +324,11 @@ This field is always read-only. * `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. * `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. +# Other Fields + +## SerializerMethodField + +This is a read-only field gets its value by calling a method on the serializer class it's attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. + [cite]: http://www.python.org/dev/peps/pep-0020/ [FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS -- cgit v1.2.3 From 3ab8c4966d065e930bd6e8bc6c26934ae5c5918c Mon Sep 17 00:00:00 2001 From: Jamie Matthews Date: Mon, 19 Nov 2012 17:24:08 +0000 Subject: Tweaks to SerializerMethodField docs --- docs/api-guide/fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index b19c324a..ebfb5d47 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -328,7 +328,7 @@ This field is always read-only. ## SerializerMethodField -This is a read-only field gets its value by calling a method on the serializer class it's attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. +This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. [cite]: http://www.python.org/dev/peps/pep-0020/ [FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS -- cgit v1.2.3 From ce5b186ca869b693c945200581ba893123a63ce8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 19 Nov 2012 21:42:33 +0000 Subject: Docs tweaks. --- docs/api-guide/authentication.md | 21 ++++++++++++--------- docs/topics/release-notes.md | 4 +++- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index a30bd22c..05575f57 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -68,7 +68,7 @@ This policy uses [HTTP Basic Authentication][basicauth], signed against a user's If successfully authenticated, `BasicAuthentication` provides the following credentials. -* `request.user` will be a `django.contrib.auth.models.User` instance. +* `request.user` will be a Django `User` instance. * `request.auth` will be `None`. **Note:** If you use `BasicAuthentication` in production you must ensure that your API is only available over `https` only. You should also ensure that your API clients will always re-request the username and password at login, and will never store those details to persistent storage. @@ -92,7 +92,7 @@ For clients to authenticate, the token key should be included in the `Authorizat If successfully authenticated, `TokenAuthentication` provides the following credentials. -* `request.user` will be a `django.contrib.auth.models.User` instance. +* `request.user` will be a Django `User` instance. * `request.auth` will be a `rest_framework.tokenauth.models.BasicToken` instance. **Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https` only. @@ -104,7 +104,7 @@ If you want every user to have an automatically generated Token, you can simply if created: Token.objects.create(user=instance) -If you've already created some User`'s, you can run a script like this. +If you've already created some User's, you can run a script like this. from django.contrib.auth.models import User from rest_framework.authtoken.models import Token @@ -112,26 +112,29 @@ If you've already created some User`'s, you can run a script like this. for user in User.objects.all(): Token.objects.get_or_create(user=user) -When using TokenAuthentication, it may be useful to add a login view for clients to retrieve the token. - -REST framework provides a built-in login view for clients to retrieve the token called `rest_framework.authtoken.obtain_auth_token`. To use it, add a pattern to include the token login view for clients as follows: +When using TokenAuthentication, you may want to provide a mechanism for clients to obtain a token, given the username and password. +REST framework provides a built-in view to provide this behavior. To use it, add the `obtain_auth_token` view to your URLconf: urlpatterns += patterns('', url(r'^api-token-auth/', 'rest_framework.authtoken.obtain_auth_token') ) -The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. The authtoken login view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using forms or JSON: +The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. + +The `obtain_auth_token` view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using form data or JSON: { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } + ## SessionAuthentication @@ -139,7 +142,7 @@ This policy uses Django's default session backend for authentication. Session a If successfully authenticated, `SessionAuthentication` provides the following credentials. -* `request.user` will be a `django.contrib.auth.models.User` instance. +* `request.user` will be a Django `User` instance. * `request.auth` will be `None`. # Custom authentication diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index d43f892f..81f4e332 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,7 +4,9 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. -* Add convenience login view to get tokens when using `TokenAuthentication` +## Master + +* Added `obtain_token_view` to get tokens when using `TokenAuthentication` ## 2.1.3 -- cgit v1.2.3 From 83f3770af12061185289ac9e4b9c0a24e82f10c3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 19 Nov 2012 21:47:34 +0000 Subject: Adding folks to the credits makes me happy. Good work @jonlil! --- docs/topics/credits.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 34590109..bd9e4f48 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -62,6 +62,7 @@ The following people have helped make REST framework great. * Ludwig Kraatz - [ludwigkraatz] * Rob Romano - [robromano] * Eugene Mechanism - [mechanism] +* Jonas Liljestrand - [jonlil] Many thanks to everyone who's contributed to the project. @@ -159,4 +160,4 @@ To contact the author directly: [ludwigkraatz]: https://github.com/ludwigkraatz [robromano]: https://github.com/robromano [mechanism]: https://github.com/mechanism - +[jonlil]: https://github.com/jonlil -- cgit v1.2.3 From 588e4dda6d97fad08b39e65df1ef25e643261977 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 19 Nov 2012 21:49:07 +0000 Subject: Added release notes --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 81f4e332..ec83387f 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,6 +7,7 @@ ## Master * Added `obtain_token_view` to get tokens when using `TokenAuthentication` +* Bugfix: Django 1.5 configurable user support for `TokenAuthentication` ## 2.1.3 -- cgit v1.2.3 From a44a94dd6ea2d9497264e267a0354cb684d398f6 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 19 Nov 2012 22:08:38 +0000 Subject: More docs tweaking. --- docs/api-guide/authentication.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 05575f57..8ed6ef31 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -104,7 +104,7 @@ If you want every user to have an automatically generated Token, you can simply if created: Token.objects.create(user=instance) -If you've already created some User's, you can run a script like this. +If you've already created some users, you can generate tokens for all existing users like this: from django.contrib.auth.models import User from rest_framework.authtoken.models import Token @@ -112,16 +112,16 @@ If you've already created some User's, you can run a script like this. for user in User.objects.all(): Token.objects.get_or_create(user=user) -When using TokenAuthentication, you may want to provide a mechanism for clients to obtain a token, given the username and password. +When using `TokenAuthentication`, you may want to provide a mechanism for clients to obtain a token given the username and password. REST framework provides a built-in view to provide this behavior. To use it, add the `obtain_auth_token` view to your URLconf: urlpatterns += patterns('', url(r'^api-token-auth/', 'rest_framework.authtoken.obtain_auth_token') ) -The `r'^api-token-auth/'` part of pattern can actually be whatever URL you want to use. +Note that the URL part of the pattern can be whatever you want to use. -The `obtain_auth_token` view will render a JSON response when a valid `username` and `password` fields are POST'ed to the view using form data or JSON: +The `obtain_auth_token` view will return a JSON response when valid `username` and `password` fields are POSTed to the view using form data or JSON: { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } -- cgit v1.2.3 From 5f4c385a86b877217c1e1bc2eaff58206eabb747 Mon Sep 17 00:00:00 2001 From: Jamie Matthews Date: Tue, 20 Nov 2012 13:25:21 +0000 Subject: Add example use of SerializerMethodField to docs --- docs/api-guide/fields.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index ebfb5d47..914d0861 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -328,7 +328,21 @@ This field is always read-only. ## SerializerMethodField -This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. +This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. For example: + + from rest_framework import serializers + from django.contrib.auth.models import User + from django.utils.timezone import now + + class UserSerializer(serializers.ModelSerializer): + + days_since_joined = serializers.SerializerMethodField('get_days_since_joined') + + class Meta: + model = User + + def get_days_since_joined(self, obj): + return (now() - obj.date_joined).days [cite]: http://www.python.org/dev/peps/pep-0020/ [FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS -- cgit v1.2.3 From 86484668f689864aa54e127a8107bdee55240cea Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Tue, 20 Nov 2012 15:38:50 +0100 Subject: added RegexField --- docs/api-guide/fields.md | 10 ++++++++++ docs/topics/release-notes.md | 1 + 2 files changed, 11 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 0485b158..cb30a52e 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -141,6 +141,16 @@ A text representation, validates the text to be a valid e-mail address. Corresponds to `django.db.models.fields.EmailField` +## RegexField + +A text representation, that validates the given value matches against a certain regular expression. + +Uses Django's `django.core.validators.RegexValidator` for validation. + +Corresponds to `django.forms.fields.RegexField` + +**Signature:** `RegexField(regex, max_length=None, min_length=None)` + ## DateField A date representation. diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 35e8a8b3..e4e67635 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -7,6 +7,7 @@ ## Master * Support for `read_only_fields` on `ModelSerializer` classes. +* Added `RegexField`. ## 2.1.2 -- cgit v1.2.3 From 3227a357cec2475b8295a67e9fd66f644ea5b0cd Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 20 Nov 2012 23:19:11 +0000 Subject: Added @irrelative for the mighty fine work. --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index bd9e4f48..955870d2 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -63,6 +63,7 @@ The following people have helped make REST framework great. * Rob Romano - [robromano] * Eugene Mechanism - [mechanism] * Jonas Liljestrand - [jonlil] +* Justin Davis - [irrelative] Many thanks to everyone who's contributed to the project. @@ -161,3 +162,4 @@ To contact the author directly: [robromano]: https://github.com/robromano [mechanism]: https://github.com/mechanism [jonlil]: https://github.com/jonlil +[irrelative]: https://github.com/irrelative -- cgit v1.2.3 From 3268c67343f6fc6364a0127a7bfabeb907a4751d Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 20 Nov 2012 23:33:56 +0000 Subject: Update docs/topics/release-notes.md --- docs/topics/release-notes.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index ec83387f..0b8a7a8f 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,6 +6,8 @@ ## Master +* Added `SerializerMethodField` +* Serializer performance improvements. * Added `obtain_token_view` to get tokens when using `TokenAuthentication` * Bugfix: Django 1.5 configurable user support for `TokenAuthentication` -- cgit v1.2.3 From 3b43d41e918b70e5ce83f7da2caabcae2e1bcd72 Mon Sep 17 00:00:00 2001 From: Mark Aaron Shirley Date: Tue, 20 Nov 2012 15:57:54 -0800 Subject: Documentation changes for partial serializer updates --- docs/api-guide/serializers.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index a9589144..624c4159 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -77,6 +77,10 @@ When deserializing data, we can either create a new instance, or update an exist serializer = CommentSerializer(data=data) # Create new instance serializer = CommentSerializer(comment, data=data) # Update `instance` +By default, serializers must be passed values for all required fields or they will throw validation errors. You can use the `partial` argument in order to allow partial updates. + + serializer = CommentSerializer(comment, data={'content': u'foo bar'}, partial=True) # Update `instance` with partial data + ## Validation When deserializing data, you always need to call `is_valid()` before attempting to access the deserialized object. If any validation errors occur, the `.errors` and `.non_field_errors` properties will contain the resulting error messages. -- cgit v1.2.3 From 9459289d7d388074045b726225cb6e140f3c18c3 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 21 Nov 2012 13:35:20 +0100 Subject: updated comparison due to pep8 programming recommendations http://www.python.org/dev/peps/pep-0008/#programming-recommendations --- docs/api-guide/serializers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index a9589144..048c1200 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -34,7 +34,7 @@ Declaring a serializer looks very similar to declaring a form: created = serializers.DateTimeField() def restore_object(self, attrs, instance=None): - if instance: + if instance is not None: instance.title = attrs['title'] instance.content = attrs['content'] instance.created = attrs['created'] -- cgit v1.2.3 From d031ccce6e693df088faa1b85dc50c0a5e636acf Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 22 Nov 2012 10:07:42 +0000 Subject: Updated release notes. --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index c641a1b3..99cc9b6d 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -16,6 +16,7 @@ **Date**: 16th Nov 2012 +* Support for partial updates with serializers. * Added `FileField` and `ImageField`. For use with `MultiPartParser`. * Added `URLField` and `SlugField`. * Support for `read_only_fields` on `ModelSerializer` classes. -- cgit v1.2.3 From df545f7a2560928fdfd8677648aa402e4f2e642b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 22 Nov 2012 10:08:14 +0000 Subject: Updated release notes. --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 99cc9b6d..9235dada 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,6 +6,7 @@ ## Master +* Support for partial updates with serializers. * Added `RegexField`. * Added `SerializerMethodField`. * Serializer performance improvements. -- cgit v1.2.3 From 4eaac26427b8574026705cdffbdf9601d620e45b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 22 Nov 2012 10:12:22 +0000 Subject: Added @dbachrach. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 955870d2..01aff6e0 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -64,6 +64,7 @@ The following people have helped make REST framework great. * Eugene Mechanism - [mechanism] * Jonas Liljestrand - [jonlil] * Justin Davis - [irrelative] +* Dustin Bachrach - [dbachrach] Many thanks to everyone who's contributed to the project. @@ -163,3 +164,4 @@ To contact the author directly: [mechanism]: https://github.com/mechanism [jonlil]: https://github.com/jonlil [irrelative]: https://github.com/irrelative +[dbachrach]: https://github.com/dbachrach \ No newline at end of file -- cgit v1.2.3 From db3dc79288f7129ceaf2d8500699920db073cbc3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 22 Nov 2012 10:16:47 +0000 Subject: Added @maspwr for the partial updates work. Ta! --- docs/topics/credits.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 01aff6e0..5323e9c0 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -65,6 +65,7 @@ The following people have helped make REST framework great. * Jonas Liljestrand - [jonlil] * Justin Davis - [irrelative] * Dustin Bachrach - [dbachrach] +* Mark Shirley - [maspwr] Many thanks to everyone who's contributed to the project. @@ -164,4 +165,5 @@ To contact the author directly: [mechanism]: https://github.com/mechanism [jonlil]: https://github.com/jonlil [irrelative]: https://github.com/irrelative -[dbachrach]: https://github.com/dbachrach \ No newline at end of file +[dbachrach]: https://github.com/dbachrach +[maspwr]: https://github.com/maspwr \ No newline at end of file -- cgit v1.2.3 From ac84c2ed2e3571b918f6c995a8f753e86c8126f1 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 22 Nov 2012 17:49:53 +0000 Subject: Version 2.1.4 --- docs/topics/release-notes.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 9235dada..fe5466be 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,7 +4,9 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. -## Master +## 2.1.4 + +**Date**: 22nd Nov 2012 * Support for partial updates with serializers. * Added `RegexField`. @@ -17,7 +19,6 @@ **Date**: 16th Nov 2012 -* Support for partial updates with serializers. * Added `FileField` and `ImageField`. For use with `MultiPartParser`. * Added `URLField` and `SlugField`. * Support for `read_only_fields` on `ModelSerializer` classes. -- cgit v1.2.3 From 95aa99d8dfc4b073bf549f5acba8ef2387512c86 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 23 Nov 2012 13:09:09 +0000 Subject: Version 2.1.5 --- docs/topics/release-notes.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index fe5466be..118e764b 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,12 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## 2.1.5 + +**Date**: 23rd Nov 2012 + +* Bugfix: Fix DjangoModelPermissions. + ## 2.1.4 **Date**: 22nd Nov 2012 -- cgit v1.2.3 From fd89bca35f065cd3917fffc79b59927460a88a3a Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 23 Nov 2012 13:21:18 +0000 Subject: Version 2.1.6. AKA: I am a doofus. --- docs/topics/release-notes.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 118e764b..867b138b 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,12 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## 2.1.6 + +**Date**: 23rd Nov 2012 + +* Bugfix: Unfix DjangoModelPermissions. (I am a doofus.) + ## 2.1.5 **Date**: 23rd Nov 2012 -- cgit v1.2.3 From e8a41322fbf96866c70ceb6b188894e02e7718f4 Mon Sep 17 00:00:00 2001 From: Yuri Prezument Date: Tue, 27 Nov 2012 11:23:40 +0200 Subject: api-guide/views.md - add imports to code example * It wasn't clear where `Response` should be imported from. --- docs/api-guide/views.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 5b072827..6cef1cd0 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -19,6 +19,9 @@ Using the `APIView` class is pretty much the same as using a regular `View` clas For example: + from rest_framework.views import APIView, Response + from rest_framework import authentication, permissions + class ListUsers(APIView): """ View to list all users in the system. -- cgit v1.2.3 From af8beb90c256586d9016d9e6411ecd9ac01f4f22 Mon Sep 17 00:00:00 2001 From: Olivier Aubert Date: Tue, 27 Nov 2012 15:19:49 +0100 Subject: Tutorial: fix module name in section 2 snippet -> snippets (to match section 1).--- docs/tutorial/2-requests-and-responses.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index b29daf05..789c2ee7 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -113,7 +113,7 @@ Now update the `urls.py` file slightly, to append a set of `format_suffix_patter from django.conf.urls import patterns, url from rest_framework.urlpatterns import format_suffix_patterns - urlpatterns = patterns('snippet.views', + urlpatterns = patterns('snippets.views', url(r'^snippets/$', 'snippet_list'), url(r'^snippets/(?P[0-9]+)$', 'snippet_detail') ) -- cgit v1.2.3 From 71129dc747fd59bfcd3b3c1ffd250988a979d30a Mon Sep 17 00:00:00 2001 From: Olivier Aubert Date: Tue, 27 Nov 2012 15:30:14 +0100 Subject: Tutorial: fix module name in section 3 Again snippet -> snippets, but then it could be simpler (and possibly intended) to rename snippets to snippet in the first section of the tutorial.--- docs/tutorial/3-class-based-views.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/3-class-based-views.md b/docs/tutorial/3-class-based-views.md index eddf6311..d87d2046 100644 --- a/docs/tutorial/3-class-based-views.md +++ b/docs/tutorial/3-class-based-views.md @@ -6,8 +6,8 @@ We can also write our API views using class based views, rather than function ba We'll start by rewriting the root view as a class based view. All this involves is a little bit of refactoring. - from snippet.models import Snippet - from snippet.serializers import SnippetSerializer + from snippets.models import Snippet + from snippets.serializers import SnippetSerializer from django.http import Http404 from rest_framework.views import APIView from rest_framework.response import Response @@ -66,7 +66,7 @@ We'll also need to refactor our URLconf slightly now we're using class based vie from django.conf.urls import patterns, url from rest_framework.urlpatterns import format_suffix_patterns - from snippetpost import views + from snippets import views urlpatterns = patterns('', url(r'^snippets/$', views.SnippetList.as_view()), @@ -85,8 +85,8 @@ The create/retrieve/update/delete operations that we've been using so far are go Let's take a look at how we can compose our views by using the mixin classes. - from snippet.models import Snippet - from snippet.serializers import SnippetSerializer + from snippets.models import Snippet + from snippets.serializers import SnippetSerializer from rest_framework import mixins from rest_framework import generics @@ -128,8 +128,8 @@ Pretty similar. This time we're using the `SingleObjectBaseView` class to provi Using the mixin classes we've rewritten the views to use slightly less code than before, but we can go one step further. REST framework provides a set of already mixed-in generic views that we can use. - from snippet.models import Snippet - from snippet.serializers import SnippetSerializer + from snippets.models import Snippet + from snippets.serializers import SnippetSerializer from rest_framework import generics -- cgit v1.2.3 From 24baf6425b82316ddedf39d44d38e22f28850fd0 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Tue, 27 Nov 2012 18:33:56 +0100 Subject: Added @oaubert Thanks! --- docs/topics/credits.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 5323e9c0..f0b51507 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -66,6 +66,7 @@ The following people have helped make REST framework great. * Justin Davis - [irrelative] * Dustin Bachrach - [dbachrach] * Mark Shirley - [maspwr] +* Olivier Aubert - [oaubert] Many thanks to everyone who's contributed to the project. @@ -166,4 +167,5 @@ To contact the author directly: [jonlil]: https://github.com/jonlil [irrelative]: https://github.com/irrelative [dbachrach]: https://github.com/dbachrach -[maspwr]: https://github.com/maspwr \ No newline at end of file +[maspwr]: https://github.com/maspwr +[oaubert]: https://github.com/oaubert \ No newline at end of file -- cgit v1.2.3 From 80be571b2e1deebff247ce5dfc4a325f2e2df9ae Mon Sep 17 00:00:00 2001 From: Yuri Prezument Date: Tue, 27 Nov 2012 19:42:37 +0200 Subject: Import from correct place --- docs/api-guide/views.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 6cef1cd0..d1e42ec1 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -19,7 +19,8 @@ Using the `APIView` class is pretty much the same as using a regular `View` clas For example: - from rest_framework.views import APIView, Response + from rest_framework.views import APIView + from rest_framework.response import Response from rest_framework import authentication, permissions class ListUsers(APIView): -- cgit v1.2.3 From 11ef60b127d38341874989a40500fe3c61771d28 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 28 Nov 2012 07:32:12 +0100 Subject: Added @yprez Thanks! --- docs/topics/credits.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index f0b51507..b53771a7 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -67,6 +67,7 @@ The following people have helped make REST framework great. * Dustin Bachrach - [dbachrach] * Mark Shirley - [maspwr] * Olivier Aubert - [oaubert] +* Yuri Prezument - [yprez] Many thanks to everyone who's contributed to the project. @@ -168,4 +169,5 @@ To contact the author directly: [irrelative]: https://github.com/irrelative [dbachrach]: https://github.com/dbachrach [maspwr]: https://github.com/maspwr -[oaubert]: https://github.com/oaubert \ No newline at end of file +[oaubert]: https://github.com/oaubert +[yprez]: https://github.com/yprez \ No newline at end of file -- cgit v1.2.3 From fd383b2b5e752962242066b3587deec5820eaa2e Mon Sep 17 00:00:00 2001 From: Pavel Savchenko Date: Wed, 28 Nov 2012 11:58:34 +0200 Subject: Fix location of obtain_auth_token view --- docs/api-guide/authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 8ed6ef31..43fc15d2 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -116,7 +116,7 @@ When using `TokenAuthentication`, you may want to provide a mechanism for client REST framework provides a built-in view to provide this behavior. To use it, add the `obtain_auth_token` view to your URLconf: urlpatterns += patterns('', - url(r'^api-token-auth/', 'rest_framework.authtoken.obtain_auth_token') + url(r'^api-token-auth/', 'rest_framework.authtoken.views.obtain_auth_token') ) Note that the URL part of the pattern can be whatever you want to use. -- cgit v1.2.3 From 8d485da483c2a5cc0713a65ef30606966c082327 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 29 Nov 2012 19:05:34 -0400 Subject: Added @fabianbuechler. Thanks! --- docs/topics/credits.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index b53771a7..e0c589b2 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -68,6 +68,7 @@ The following people have helped make REST framework great. * Mark Shirley - [maspwr] * Olivier Aubert - [oaubert] * Yuri Prezument - [yprez] +* Fabian Buechler - [fabianbuechler] Many thanks to everyone who's contributed to the project. @@ -170,4 +171,5 @@ To contact the author directly: [dbachrach]: https://github.com/dbachrach [maspwr]: https://github.com/maspwr [oaubert]: https://github.com/oaubert -[yprez]: https://github.com/yprez \ No newline at end of file +[yprez]: https://github.com/yprez +[fabianbuechler]: https://github.com/fabianbuechler -- cgit v1.2.3 From 3e8336af5000a2ae9554d3e1a220ad7510c16f42 Mon Sep 17 00:00:00 2001 From: mvdwaeter Date: Fri, 30 Nov 2012 21:50:51 +0100 Subject: Fixed typo in import statement of tutorial --- docs/tutorial/2-requests-and-responses.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index 789c2ee7..187effb9 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -41,8 +41,8 @@ We don't need our `JSONResponse` class anymore, so go ahead and delete that. On from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response - from snippet.models import Snippet - from snippet.serializers import SnippetSerializer + from snippets.models import Snippet + from snippets.serializers import SnippetSerializer @api_view(['GET', 'POST']) -- cgit v1.2.3 From 45d28f49e03a394bfcfc6348558ec5bd4bac2b6c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sun, 2 Dec 2012 11:04:34 -0400 Subject: Added @mhsparks. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index e0c589b2..75a2d596 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -69,6 +69,7 @@ The following people have helped make REST framework great. * Olivier Aubert - [oaubert] * Yuri Prezument - [yprez] * Fabian Buechler - [fabianbuechler] +* Mark Hughes - [mhsparks] Many thanks to everyone who's contributed to the project. @@ -173,3 +174,4 @@ To contact the author directly: [oaubert]: https://github.com/oaubert [yprez]: https://github.com/yprez [fabianbuechler]: https://github.com/fabianbuechler +[mhsparks]: https://github.com/mhsparks -- cgit v1.2.3 From 3e3ede71d2f4826fa1d07523705dd53ab2cba29a Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Mon, 3 Dec 2012 12:47:12 +0100 Subject: Added @mvdwaeter. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 75a2d596..f2f09c0e 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -70,6 +70,7 @@ The following people have helped make REST framework great. * Yuri Prezument - [yprez] * Fabian Buechler - [fabianbuechler] * Mark Hughes - [mhsparks] +* Michael van de Waeter - [mvdwaeter] Many thanks to everyone who's contributed to the project. @@ -175,3 +176,4 @@ To contact the author directly: [yprez]: https://github.com/yprez [fabianbuechler]: https://github.com/fabianbuechler [mhsparks]: https://github.com/mhsparks +[mvdwaeter]: https://github.com/mvdwaeter -- cgit v1.2.3 From e044fa089b5ccdcc3557a65c106fad0f44f1b7b8 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Tue, 4 Dec 2012 09:40:23 +0100 Subject: fixed #469 - RegexField <--> BrowsableAPI Bug --- docs/topics/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 867b138b..c2fe3f64 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,10 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## Master + +* Bugfix: Fix `RegexField` to work with `BrowsableAPIRenderer` + ## 2.1.6 **Date**: 23rd Nov 2012 -- cgit v1.2.3 From fc6dbb45e023a5e5e6c92bd434b93350c4fbb8d3 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 5 Dec 2012 12:20:03 +0100 Subject: Fixed wording. --- docs/tutorial/quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/tutorial/quickstart.md b/docs/tutorial/quickstart.md index 9a36a2b0..74084541 100644 --- a/docs/tutorial/quickstart.md +++ b/docs/tutorial/quickstart.md @@ -137,7 +137,7 @@ We'd also like to set a few global settings. We'd like to turn on pagination, a 'PAGINATE_BY': 10 } -Okay, that's us done. +Okay, we're done. --- -- cgit v1.2.3 From 3417c4631d0680aee14f7b06435d00c25ce5b464 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 5 Dec 2012 12:31:38 +0100 Subject: Fixed typos and fixed wording. Some singular/plural fixes. Fixed some 'serialise->serialize' kind of UK/US differences. The 'z' seems more common in the rest of the docs, so that's what I used. Removed a half-finished-sentence left dangling somewhere.--- docs/tutorial/1-serialization.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md index ba64f2aa..e61fb946 100644 --- a/docs/tutorial/1-serialization.md +++ b/docs/tutorial/1-serialization.md @@ -14,7 +14,7 @@ The tutorial is fairly in-depth, so you should probably get a cookie and a cup o ## Setting up a new environment -Before we do anything else we'll create a new virtual environment, using [virtualenv]. This will make sure our package configuration is keep nicely isolated from any other projects we're working on. +Before we do anything else we'll create a new virtual environment, using [virtualenv]. This will make sure our package configuration is kept nicely isolated from any other projects we're working on. :::bash mkdir ~/env @@ -39,7 +39,6 @@ To get started, let's create a new project to work with. cd tutorial Once that's done we can create an app that we'll use to create a simple Web API. -We're going to create a project that python manage.py startapp snippets @@ -64,7 +63,7 @@ We'll also need to add our new `snippets` app and the `rest_framework` app to `I 'snippets' ) -We also need to wire up the root urlconf, in the `tutorial/urls.py` file, to include our snippet views. +We also need to wire up the root urlconf, in the `tutorial/urls.py` file, to include our snippet app's URLs. urlpatterns = patterns('', url(r'^', include('snippets.urls')), @@ -105,7 +104,7 @@ Don't forget to sync the database for the first time. ## Creating a Serializer class -The first thing we need to get started on our Web API is provide a way of serializing and deserializing the snippet instances into representations such as `json`. We can do this by declaring serializers that work very similarly to Django's forms. Create a file in the `snippets` directory named `serializers.py` and add the following. +The first thing we need to get started on our Web API is provide a way of serializing and deserializing the snippet instances into representations such as `json`. We can do this by declaring serializers that work very similar to Django's forms. Create a file in the `snippets` directory named `serializers.py` and add the following. from django.forms import widgets from rest_framework import serializers @@ -146,7 +145,7 @@ We can actually also save ourselves some time by using the `ModelSerializer` cla ## Working with Serializers -Before we go any further we'll familiarise ourselves with using our new Serializer class. Let's drop into the Django shell. +Before we go any further we'll familiarize ourselves with using our new Serializer class. Let's drop into the Django shell. python manage.py shell @@ -166,7 +165,7 @@ We've now got a few snippet instances to play with. Let's take a look at serial serializer.data # {'pk': 1, 'title': u'', 'code': u'print "hello, world"\n', 'linenos': False, 'language': u'python', 'style': u'friendly'} -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`. content = JSONRenderer().render(serializer.data) content @@ -292,7 +291,7 @@ Finally we need to wire these views up. Create the `snippets/urls.py` file: url(r'^snippets/(?P[0-9]+)/$', 'snippet_detail') ) -It's worth noting that there's a couple of edge cases we're not dealing with properly at the moment. If we send malformed `json`, or if a request is made with a method that the view doesn't handle, then we'll end up with a 500 "server error" response. Still, this'll do for now. +It's worth noting that there are a couple of edge cases we're not dealing with properly at the moment. If we send malformed `json`, or if a request is made with a method that the view doesn't handle, then we'll end up with a 500 "server error" response. Still, this'll do for now. ## Testing our first attempt at a Web API @@ -304,7 +303,7 @@ It's worth noting that there's a couple of edge cases we're not dealing with pro We're doing okay so far, we've got a serialization API that feels pretty similar to Django's Forms API, and some regular Django views. -Our API views don't do anything particularly special at the moment, beyond serve `json` responses, and there's some error handling edge cases we'd still like to clean up, but it's a functioning Web API. +Our API views don't do anything particularly special at the moment, beyond serving `json` responses, and there are some error handling edge cases we'd still like to clean up, but it's a functioning Web API. We'll see how we can start to improve things in [part 2 of the tutorial][tut-2]. -- cgit v1.2.3 From 3868241f6acda96fbd08cc81211b09ffbc2f38b3 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Wed, 5 Dec 2012 15:09:06 +0100 Subject: Update docs/api-guide/permissions.md @permission_classes takes a tuple or list.--- docs/api-guide/permissions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md index 1a746fb6..fce68f6d 100644 --- a/docs/api-guide/permissions.md +++ b/docs/api-guide/permissions.md @@ -53,7 +53,7 @@ You can also set the authentication policy on a per-view basis, using the `APIVi Or, if you're using the `@api_view` decorator with function based views. @api_view('GET') - @permission_classes(IsAuthenticated) + @permission_classes((IsAuthenticated, )) def example_view(request, format=None): content = { 'status': 'request was permitted' -- cgit v1.2.3 From cb4e85721717517c9afd86c5e5e027ba19885b27 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 5 Dec 2012 16:04:52 +0100 Subject: Textual fixes. Added a sentence introducing the second view. Fix one or two additional sentences.--- docs/tutorial/2-requests-and-responses.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index 187effb9..08cf91cd 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -66,6 +66,8 @@ We don't need our `JSONResponse` class anymore, so go ahead and delete that. On Our instance view is an improvement over the previous example. It's a little more concise, and the code now feels very similar to if we were working with the Forms API. We're also using named status codes, which makes the response meanings more obvious. +Here is the view for an individual snippet. + @api_view(['GET', 'PUT', 'DELETE']) def snippet_detail(request, pk): """ @@ -92,7 +94,7 @@ Our instance view is an improvement over the previous example. It's a little mo snippet.delete() return Response(status=status.HTTP_204_NO_CONTENT) -This should all feel very familiar - there's not a lot different to working with regular Django views. +This should all feel very familiar - it is not a lot different from working with regular Django views. Notice that we're no longer explicitly tying our requests or responses to a given content type. `request.DATA` can handle incoming `json` requests, but it can also handle `yaml` and other formats. Similarly we're returning response objects with data, but allowing REST framework to render the response into the correct content type for us. @@ -128,7 +130,7 @@ Go ahead and test the API from the command line, as we did in [tutorial part 1][ **TODO: Describe using accept headers, content-type headers, and format suffixed URLs** -Now go and open the API in a web browser, by visiting [http://127.0.0.1:8000/snippets/][devserver]." +Now go and open the API in a web browser, by visiting [http://127.0.0.1:8000/snippets/][devserver]. ### Browsability -- cgit v1.2.3 From ee184b86292d347ba747ee4a438f17e4fc613947 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 5 Dec 2012 16:08:13 +0100 Subject: Small textual fixes. --- docs/tutorial/3-class-based-views.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/3-class-based-views.md b/docs/tutorial/3-class-based-views.md index d87d2046..a3a18060 100644 --- a/docs/tutorial/3-class-based-views.md +++ b/docs/tutorial/3-class-based-views.md @@ -102,7 +102,7 @@ Let's take a look at how we can compose our views by using the mixin classes. def post(self, request, *args, **kwargs): return self.create(request, *args, **kwargs) -We'll take a moment to examine exactly what's happening here - We're building our view using `MultipleObjectAPIView`, and adding in `ListModelMixin` and `CreateModelMixin`. +We'll take a moment to examine exactly what's happening here. We're building our view using `MultipleObjectAPIView`, and adding in `ListModelMixin` and `CreateModelMixin`. The base class provides the core functionality, and the mixin classes provide the `.list()` and `.create()` actions. We're then explicitly binding the `get` and `post` methods to the appropriate actions. Simple enough stuff so far. @@ -142,7 +142,7 @@ Using the mixin classes we've rewritten the views to use slightly less code than model = Snippet serializer_class = SnippetSerializer -Wow, that's pretty concise. We've got a huge amount for free, and our code looks like good, clean, idiomatic Django. +Wow, that's pretty concise. We've gotten a huge amount for free, and our code looks like good, clean, idiomatic Django. Next we'll move onto [part 4 of the tutorial][tut-4], where we'll take a look at how we can deal with authentication and permissions for our API. -- cgit v1.2.3 From 3f39828788d856bb7923bfb3acf801e571597e55 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 5 Dec 2012 16:16:46 +0100 Subject: Small textual fixes. --- docs/tutorial/4-authentication-and-permissions.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md index f85250be..9576a7f0 100644 --- a/docs/tutorial/4-authentication-and-permissions.md +++ b/docs/tutorial/4-authentication-and-permissions.md @@ -61,7 +61,7 @@ Now that we've got some users to work with, we'd better add representations of t model = User fields = ('id', 'username', 'snippets') -Because `'snippets'` is a *reverse* relationship on the User model, it will not be included by default when using the `ModelSerializer` class, so we've needed to add an explicit field for it. +Because `'snippets'` is a *reverse* relationship on the User model, it will not be included by default when using the `ModelSerializer` class, so we needed to add an explicit field for it. We'll also add a couple of views. We'd like to just use read-only views for the user representations, so we'll use the `ListAPIView` and `RetrieveAPIView` generic class based views. @@ -92,9 +92,7 @@ On **both** the `SnippetList` and `SnippetDetail` view classes, add the followin ## Updating our serializer -Now that snippets are associated with the user that created them, let's update our SnippetSerializer to reflect that. - -Add the following field to the serializer definition: +Now that snippets are associated with the user that created them, let's update our `SnippetSerializer` to reflect that. Add the following field to the serializer definition: owner = serializers.Field(source='owner.username') @@ -108,7 +106,7 @@ The field we've added is the untyped `Field` class, in contrast to the other typ ## Adding required permissions to views -Now that code snippets are associated with users we want to make sure that only authenticated users are able to create, update and delete code snippets. +Now that code snippets are associated with users, we want to make sure that only authenticated users are able to create, update and delete code snippets. REST framework includes a number of permission classes that we can use to restrict who can access a given view. In this case the one we're looking for is `IsAuthenticatedOrReadOnly`, which will ensure that authenticated requests get read-write access, and unauthenticated requests get read-only access. -- cgit v1.2.3 From 7a110a3006b47e61c12dd5ec9e62b278d1b17298 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Wed, 5 Dec 2012 16:24:41 +0100 Subject: Two typo fixes. Plural/singular fix. Typo fixed.--- docs/tutorial/5-relationships-and-hyperlinked-apis.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md index 98c45b82..b5d37875 100644 --- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md +++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md @@ -25,7 +25,7 @@ Notice that we're using REST framework's `reverse` function in order to return f The other obvious thing that's still missing from our pastebin API is the code highlighting endpoints. -Unlike all our other API endpoints, we don't want to use JSON, but instead just present an HTML representation. There are two style of HTML renderer provided by REST framework, one for dealing with HTML rendered using templates, the other for dealing with pre-rendered HTML. The second renderer is the one we'd like to use for this endpoint. +Unlike all our other API endpoints, we don't want to use JSON, but instead just present an HTML representation. There are two styles of HTML renderer provided by REST framework, one for dealing with HTML rendered using templates, the other for dealing with pre-rendered HTML. The second renderer is the one we'd like to use for this endpoint. The other thing we need to consider when creating the code highlight view is that there's no existing concrete generic view that we can use. We're not returning an object instance, but instead a property of an object instance. @@ -151,7 +151,7 @@ We could also customize the pagination style if we needed too, but in this case If we open a browser and navigate to the browseable API, you'll find that you can now work your way around the API simply by following links. -You'll also be able to see the 'highlight' links on the snippet instances, that will take you to the hightlighted code HTML representations. +You'll also be able to see the 'highlight' links on the snippet instances, that will take you to the highlighted code HTML representations. We've now got a complete pastebin Web API, which is fully web browseable, and comes complete with authentication, per-object permissions, and multiple renderer formats. -- cgit v1.2.3 From 2938bc13b12ec73084c21e629bdde4a20a1de0cb Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 6 Dec 2012 16:30:22 -0400 Subject: Added @reinout for the copy fixes. Thanks! --- docs/topics/credits.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index f2f09c0e..a2e0a23f 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -71,6 +71,7 @@ The following people have helped make REST framework great. * Fabian Buechler - [fabianbuechler] * Mark Hughes - [mhsparks] * Michael van de Waeter - [mvdwaeter] +* Reinout van Rees - [reinout] Many thanks to everyone who's contributed to the project. @@ -177,3 +178,5 @@ To contact the author directly: [fabianbuechler]: https://github.com/fabianbuechler [mhsparks]: https://github.com/mhsparks [mvdwaeter]: https://github.com/mvdwaeter +[reinout]: https://github.com/reinout + -- cgit v1.2.3 From 6a5f4f2a90ab19a8586a9d762c9b2618e8db5c30 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 6 Dec 2012 22:38:20 +0000 Subject: Added @justanotherbody. Thanks! --- docs/topics/credits.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index a2e0a23f..9e59d678 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -72,6 +72,7 @@ The following people have helped make REST framework great. * Mark Hughes - [mhsparks] * Michael van de Waeter - [mvdwaeter] * Reinout van Rees - [reinout] +* Michael Richards - [justanotherbody] Many thanks to everyone who's contributed to the project. @@ -179,4 +180,4 @@ To contact the author directly: [mhsparks]: https://github.com/mhsparks [mvdwaeter]: https://github.com/mvdwaeter [reinout]: https://github.com/reinout - +[justanotherbody]: https://github.com/justanotherbody -- cgit v1.2.3 From 26cfa023263576258e53fe23bc92e437398ff15f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 6 Dec 2012 22:56:23 +0000 Subject: Added @roberts81. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 9e59d678..dfa1ee0f 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -73,6 +73,7 @@ The following people have helped make REST framework great. * Michael van de Waeter - [mvdwaeter] * Reinout van Rees - [reinout] * Michael Richards - [justanotherbody] +* Ben Roberts - [roberts81] Many thanks to everyone who's contributed to the project. @@ -181,3 +182,4 @@ To contact the author directly: [mvdwaeter]: https://github.com/mvdwaeter [reinout]: https://github.com/reinout [justanotherbody]: https://github.com/justanotherbody +[roberts81]: https://github.com/roberts81 -- cgit v1.2.3 From 21f7dcf7c6da2e47f3b14d10018dfe6d0d060449 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 7 Dec 2012 22:25:28 +0000 Subject: Added release notes --- docs/topics/release-notes.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index c2fe3f64..91cbb2fc 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,6 +6,12 @@ ## Master +* Serializers now properly support nullable Foreign Keys. +* Serializer validation now includes model field validation, such as uniqueness constraints. +* Support 'true' and 'false' string values for BooleanField. +* Added pickle support for serialized data. +* Support `source='dotted.notation'` style for nested serializers. +* Make `Request.user` settable. * Bugfix: Fix `RegexField` to work with `BrowsableAPIRenderer` ## 2.1.6 -- cgit v1.2.3 From b170973993cb269e2a061ab592d272ec9b67c86f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 7 Dec 2012 22:36:30 +0000 Subject: Version 2.1.7 --- docs/topics/release-notes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 91cbb2fc..5b371d01 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,7 +4,9 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. -## Master +## 2.1.7 + +**Date**: 7th Dec 2012 * Serializers now properly support nullable Foreign Keys. * Serializer validation now includes model field validation, such as uniqueness constraints. -- cgit v1.2.3 From c1be29418b7cd8f2b44a7c3273cc79f024fa8c45 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 7 Dec 2012 23:58:20 +0000 Subject: Add link to json+hal hypermedia format. --- docs/topics/rest-hypermedia-hateoas.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/rest-hypermedia-hateoas.md b/docs/topics/rest-hypermedia-hateoas.md index d7646892..10ab9dfe 100644 --- a/docs/topics/rest-hypermedia-hateoas.md +++ b/docs/topics/rest-hypermedia-hateoas.md @@ -32,7 +32,7 @@ REST framework also includes [serialization] and [parser]/[renderer] components ## What REST framework doesn't provide. -What REST framework doesn't do is give you is machine readable hypermedia formats such as [Collection+JSON][collection] 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 is machine readable hypermedia formats such as [HAL][hal], [Collection+JSON][collection] 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. [cite]: http://vimeo.com/channels/restfest/page:2 [dissertation]: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm @@ -44,6 +44,7 @@ What REST framework doesn't do is give you is machine readable hypermedia format [readinglist]: http://blog.steveklabnik.com/posts/2012-02-27-hypermedia-api-reading-list [maturitymodel]: http://martinfowler.com/articles/richardsonMaturityModel.html +[hal]: http://stateless.co/hal_specification.html [collection]: http://www.amundsen.com/media-types/collection/ [microformats]: http://microformats.org/wiki/Main_Page [serialization]: ../api-guide/serializers.md -- cgit v1.2.3 From ff01ae3571298b9da67f9b9583f0cb264676ed2b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 8 Dec 2012 13:01:03 +0000 Subject: Version 2.1.8 --- docs/api-guide/fields.md | 3 +++ docs/topics/release-notes.md | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 1d4c34cb..50a09701 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -293,6 +293,7 @@ By default these fields are read-write, although you can change this behaviour u **Arguments**: * `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. +* `null` - If set to `True`, the field will accept values of `None` or the emptystring for nullable relationships. ## SlugRelatedField / ManySlugRelatedField @@ -304,6 +305,7 @@ By default these fields read-write, although you can change this behaviour using * `slug_field` - The field on the target that should be used to represent it. This should be a field that uniquely identifies any given instance. For example, `username`. * `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. +* `null` - If set to `True`, the field will accept values of `None` or the emptystring for nullable relationships. ## HyperlinkedRelatedField / ManyHyperlinkedRelatedField @@ -319,6 +321,7 @@ By default, `HyperlinkedRelatedField` is read-write, although you can change thi * `slug_field` - The field on the target that should be used for the lookup. Default is `'slug'`. * `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. * `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. +* `null` - If set to `True`, the field will accept values of `None` or the emptystring for nullable relationships. ## HyperLinkedIdentityField diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 5b371d01..46eb1494 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,13 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## 2.1.8 + +**Date**: 8th Dec 2012 + +* Fix for creating nullable Foreign Keys with `''` as well as `None`. +* Added `null=` related field option. + ## 2.1.7 **Date**: 7th Dec 2012 @@ -14,7 +21,7 @@ * Added pickle support for serialized data. * Support `source='dotted.notation'` style for nested serializers. * Make `Request.user` settable. -* Bugfix: Fix `RegexField` to work with `BrowsableAPIRenderer` +* Bugfix: Fix `RegexField` to work with `BrowsableAPIRenderer`. ## 2.1.6 -- cgit v1.2.3 From 80adaecc4307ba802fcb7e45b2f178d2102a41e9 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 11 Dec 2012 09:04:47 +0000 Subject: Added @annacoder. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index dfa1ee0f..dc98dccb 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -74,6 +74,7 @@ The following people have helped make REST framework great. * Reinout van Rees - [reinout] * Michael Richards - [justanotherbody] * Ben Roberts - [roberts81] +* Venkata Subramanian Mahalingam - [annacoder] Many thanks to everyone who's contributed to the project. @@ -183,3 +184,4 @@ To contact the author directly: [reinout]: https://github.com/reinout [justanotherbody]: https://github.com/justanotherbody [roberts81]: https://github.com/roberts81 +[annacoder]: https://github.com/annacoder -- cgit v1.2.3 From 17b77fc446df29e7708c210eade8369c7babc466 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 11 Dec 2012 21:07:11 +0000 Subject: Added @gkrappel. Thank you! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index dc98dccb..674c8378 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -75,6 +75,7 @@ The following people have helped make REST framework great. * Michael Richards - [justanotherbody] * Ben Roberts - [roberts81] * Venkata Subramanian Mahalingam - [annacoder] +* George Kappel - [gkappel] Many thanks to everyone who's contributed to the project. @@ -185,3 +186,4 @@ To contact the author directly: [justanotherbody]: https://github.com/justanotherbody [roberts81]: https://github.com/roberts81 [annacoder]: https://github.com/annacoder +[gkappel]: https://github.com/gkappel -- cgit v1.2.3 From 0824761f471ee5130af980acc9fdbb2758a3a92a Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 11 Dec 2012 21:07:48 +0000 Subject: Version 2.1.9 --- docs/topics/release-notes.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 46eb1494..4f83cfd8 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,14 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## 2.1.9 + +**Date**: 11th Dec 2012 + +* Bugfix: Fix broken nested serialization. +* Bugfix: Fix `Meta.fields` only working as tuple not as list. +* Bugfix: Edge case if unnecessarily specifying `required=False` on read only field. + ## 2.1.8 **Date**: 8th Dec 2012 -- cgit v1.2.3 From 9188d487c3a0465b2a3e0d1c47f76c3df844b7d0 Mon Sep 17 00:00:00 2001 From: Colin Murtaugh Date: Tue, 11 Dec 2012 17:26:08 -0500 Subject: Replaced SingleObjectBaseView with SingleObjectAPIView --- docs/tutorial/3-class-based-views.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorial/3-class-based-views.md b/docs/tutorial/3-class-based-views.md index a3a18060..b115b022 100644 --- a/docs/tutorial/3-class-based-views.md +++ b/docs/tutorial/3-class-based-views.md @@ -109,7 +109,7 @@ The base class provides the core functionality, and the mixin classes provide th class SnippetDetail(mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, - generics.SingleObjectBaseView): + generics.SingleObjectAPIView): model = Snippet serializer_class = SnippetSerializer @@ -122,7 +122,7 @@ The base class provides the core functionality, and the mixin classes provide th def delete(self, request, *args, **kwargs): return self.destroy(request, *args, **kwargs) -Pretty similar. This time we're using the `SingleObjectBaseView` class to provide the core functionality, and adding in mixins to provide the `.retrieve()`, `.update()` and `.destroy()` actions. +Pretty similar. This time we're using the `SingleObjectAPIView` class to provide the core functionality, and adding in mixins to provide the `.retrieve()`, `.update()` and `.destroy()` actions. ## Using generic class based views -- cgit v1.2.3 From 628e3bf001ca71da48a6f3c7bbdf209f2e20b223 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 12 Dec 2012 08:59:19 +0100 Subject: Added @cmurtaugh. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 674c8378..cdf57f7e 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -76,6 +76,7 @@ The following people have helped make REST framework great. * Ben Roberts - [roberts81] * Venkata Subramanian Mahalingam - [annacoder] * George Kappel - [gkappel] +* Colin Murtaugh - [cmurtaugh] Many thanks to everyone who's contributed to the project. @@ -187,3 +188,4 @@ To contact the author directly: [roberts81]: https://github.com/roberts81 [annacoder]: https://github.com/annacoder [gkappel]: https://github.com/gkappel +[cmurtaugh]: https://github.com/cmurtaugh -- cgit v1.2.3 From e198a2b37673a07a7cc374175c205362da34360e Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Thu, 13 Dec 2012 16:57:17 +0100 Subject: added RetrieveUpdateAPIView --- docs/api-guide/generic-views.md | 8 ++++++++ docs/topics/release-notes.md | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 428323b8..ef09dfe5 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -97,6 +97,14 @@ Provides `get` and `post` method handlers. Extends: [MultipleObjectAPIView], [ListModelMixin], [CreateModelMixin] +## RetrieveUpdateAPIView + +Used for **read or update** endpoints to represent a **single model instance**. + +Provides `get` and `put` method handlers. + +Extends: [SingleObjectAPIView], [RetrieveModelMixin], [UpdateModelMixin] + ## RetrieveDestroyAPIView Used for **read or delete** endpoints to represent a **single model instance**. diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 4f83cfd8..a74ee520 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,6 +4,10 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. +## Master + +* Added `RetrieveUpdateAPIView` + ## 2.1.9 **Date**: 11th Dec 2012 -- cgit v1.2.3 From 6f8b432677f001c46128ed6f20b2efbcf2a70feb Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 14 Dec 2012 20:08:43 +0000 Subject: Added @pilt. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index cdf57f7e..e0bb366b 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -77,6 +77,7 @@ The following people have helped make REST framework great. * Venkata Subramanian Mahalingam - [annacoder] * George Kappel - [gkappel] * Colin Murtaugh - [cmurtaugh] +* Simon Pantzare - [pilt] Many thanks to everyone who's contributed to the project. @@ -189,3 +190,4 @@ To contact the author directly: [annacoder]: https://github.com/annacoder [gkappel]: https://github.com/gkappel [cmurtaugh]: https://github.com/cmurtaugh +[pilt]: https://github.com/pilt -- cgit v1.2.3 From e9eb47207a7e599c09d9eda4e2f9adfe03ef4542 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 14 Dec 2012 20:08:53 +0000 Subject: Update release notes. --- docs/topics/release-notes.md | 74 +++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 25 deletions(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 4f83cfd8..4ea393af 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,7 +4,13 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. -## 2.1.9 +## 2.1.x series + +### Master + +* Bugfix: Fix hyperlinked fields in paginated results. + +### 2.1.9 **Date**: 11th Dec 2012 @@ -12,14 +18,14 @@ * Bugfix: Fix `Meta.fields` only working as tuple not as list. * Bugfix: Edge case if unnecessarily specifying `required=False` on read only field. -## 2.1.8 +### 2.1.8 **Date**: 8th Dec 2012 * Fix for creating nullable Foreign Keys with `''` as well as `None`. * Added `null=` related field option. -## 2.1.7 +### 2.1.7 **Date**: 7th Dec 2012 @@ -31,19 +37,19 @@ * Make `Request.user` settable. * Bugfix: Fix `RegexField` to work with `BrowsableAPIRenderer`. -## 2.1.6 +### 2.1.6 **Date**: 23rd Nov 2012 * Bugfix: Unfix DjangoModelPermissions. (I am a doofus.) -## 2.1.5 +### 2.1.5 **Date**: 23rd Nov 2012 * Bugfix: Fix DjangoModelPermissions. -## 2.1.4 +### 2.1.4 **Date**: 22nd Nov 2012 @@ -54,7 +60,7 @@ * Added `obtain_token_view` to get tokens when using `TokenAuthentication`. * Bugfix: Django 1.5 configurable user support for `TokenAuthentication`. -## 2.1.3 +### 2.1.3 **Date**: 16th Nov 2012 @@ -65,14 +71,14 @@ * 201 Responses now return a 'Location' header. * Bugfix: Serializer fields now respect `max_length`. -## 2.1.2 +### 2.1.2 **Date**: 9th Nov 2012 * **Filtering support.** * Bugfix: Support creation of objects with reverse M2M relations. -## 2.1.1 +### 2.1.1 **Date**: 7th Nov 2012 @@ -82,7 +88,7 @@ * Bugfix: Make textareas same width as other fields in browsable API. * Private API change: `.get_serializer` now uses same `instance` and `data` ordering as serializer initialization. -## 2.1.0 +### 2.1.0 **Date**: 5th Nov 2012 @@ -96,13 +102,17 @@ * Bugfix: Support choice field in Browseable API. * Bugfix: Related fields with `read_only=True` do not require a `queryset` argument. -## 2.0.2 +--- + +## 2.0.x series + +### 2.0.2 **Date**: 2nd Nov 2012 * Fix issues with pk related fields in the browsable API. -## 2.0.1 +### 2.0.1 **Date**: 1st Nov 2012 @@ -110,7 +120,7 @@ * Added SlugRelatedField and ManySlugRelatedField. * If PUT creates an instance return '201 Created', instead of '200 OK'. -## 2.0.0 +### 2.0.0 **Date**: 30th Oct 2012 @@ -119,7 +129,9 @@ --- -## 0.4.0 +## 0.4.x series + +### 0.4.0 * Supports Django 1.5. * Fixes issues with 'HEAD' method. @@ -131,7 +143,11 @@ * Improve setup (eg use staticfiles, not the defunct ADMIN_MEDIA_PREFIX) * Sensible absolute URL generation, not using hacky set_script_prefix -## 0.3.3 +--- + +## 0.3.x series + +### 0.3.3 * Added DjangoModelPermissions class to support `django.contrib.auth` style permissions. * Use `staticfiles` for css files. @@ -146,7 +162,7 @@ * Bugfixes: - Bug with PerUserThrottling when user contains unicode chars. -## 0.3.2 +### 0.3.2 * Bugfixes: * Fix 403 for POST and PUT from the UI with UserLoggedInAuthentication (#115) @@ -158,37 +174,41 @@ * get_name, get_description become methods on the view - makes them overridable. * Improved model mixin API - Hooks for build_query, get_instance_data, get_model, get_queryset, get_ordering -## 0.3.1 +### 0.3.1 * [not documented] -## 0.3.0 +### 0.3.0 * JSONP Support * Bugfixes, including support for latest markdown release -## 0.2.4 +--- + +## 0.2.x series + +### 0.2.4 * Fix broken IsAdminUser permission. * OPTIONS support. * XMLParser. * Drop mentions of Blog, BitBucket. -## 0.2.3 +### 0.2.3 * Fix some throttling bugs. * ``X-Throttle`` header on throttling. * Support for nesting resources on related models. -## 0.2.2 +### 0.2.2 * Throttling support complete. -## 0.2.1 +### 0.2.1 * Couple of simple bugfixes over 0.2.0 -## 0.2.0 +### 0.2.0 * Big refactoring changes since 0.1.0, ask on the discussion group if anything isn't clear. The public API has been massively cleaned up. Expect it to be fairly stable from here on in. @@ -212,11 +232,15 @@ * The mixin classes have been nicely refactored, the basic mixins are now ``RequestMixin``, ``ResponseMixin``, ``AuthMixin``, and ``ResourceMixin`` You can reuse these mixin classes individually without using the ``View`` class. -## 0.1.1 +--- + +## 0.1.x series + +### 0.1.1 * Final build before pulling in all the refactoring changes for 0.2, in case anyone needs to hang on to 0.1. -## 0.1.0 +### 0.1.0 * Initial release. -- cgit v1.2.3 From 1d24d1fc5928d32372e700907aa71cf887b16ba9 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 14 Dec 2012 20:14:42 +0000 Subject: Added @sunscrapers. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index e0bb366b..ba37ce11 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -78,6 +78,7 @@ The following people have helped make REST framework great. * George Kappel - [gkappel] * Colin Murtaugh - [cmurtaugh] * Simon Pantzare - [pilt] +* Szymon Teżewski - [sunscrapers] Many thanks to everyone who's contributed to the project. @@ -191,3 +192,4 @@ To contact the author directly: [gkappel]: https://github.com/gkappel [cmurtaugh]: https://github.com/cmurtaugh [pilt]: https://github.com/pilt +[sunscrapers]: https://github.com/sunscrapers -- cgit v1.2.3 From 35f72cecb199e1790a42fadd6037da43cdd5a05a Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 15 Dec 2012 20:40:41 +0000 Subject: Fix model validation exclusions. Fixes #500. Fixes #506. --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 4ea393af..6d7dc348 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -8,6 +8,7 @@ ### Master +* Bugfix: Ensure read-only fields don't have model validation applied. * Bugfix: Fix hyperlinked fields in paginated results. ### 2.1.9 -- cgit v1.2.3 From 70714c234630cd205ed88686ece3b594f387a48f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 17 Dec 2012 09:08:28 +0000 Subject: Version 2.1.10 --- docs/topics/release-notes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 6d7dc348..66d6f7f3 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,7 +6,9 @@ ## 2.1.x series -### Master +### 2.1.10 + +**Date**: 17th Dec 2012 * Bugfix: Ensure read-only fields don't have model validation applied. * Bugfix: Fix hyperlinked fields in paginated results. -- cgit v1.2.3 From 0418cebc583711263d983e0e3acbd474eb6f0fd2 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 17 Dec 2012 22:00:25 +0000 Subject: Update contact details --- docs/topics/credits.md | 6 +++--- docs/tutorial/5-relationships-and-hyperlinked-apis.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index ba37ce11..c169fd74 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -98,10 +98,9 @@ Development of REST framework 2.0 was sponsored by [DabApps]. ## Contact -To contact the author directly: +For usage questions please see the [REST framework discussion group][group]. -* twitter: [@_tomchristie][twitter] -* email: [tom@tomchristie.com][email] +You can also contact [@_tomchristie][twitter] directly on twitter. [email]: mailto:tom@tomchristie.com [twitter]: http://twitter.com/_tomchristie @@ -115,6 +114,7 @@ To contact the author directly: [dabapps]: http://lab.dabapps.com [sandbox]: http://restframework.herokuapp.com/ [heroku]: http://www.heroku.com/ +[group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework [tomchristie]: https://github.com/tomchristie [markotibold]: https://github.com/markotibold diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md index b5d37875..216ca433 100644 --- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md +++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md @@ -163,9 +163,9 @@ You can review the final [tutorial code][repo] on GitHub, or try out a live exam We've reached the end of our tutorial. If you want to get more involved in the REST framework project, here's a few places you can start: -* Contribute on [GitHub][github] by reviewing and subitting issues, and making pull requests. +* Contribute on [GitHub][github] by reviewing and submitting issues, and making pull requests. * Join the [REST framework discussion group][group], and help build the community. -* Follow the author [on Twitter][twitter] and say hi. +* [Follow the author on Twitter][twitter] and say hi. **Now go build awesome things.** -- cgit v1.2.3 From 9680b42b506a47df1cac83107aff15bfd4a99a48 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 17 Dec 2012 22:01:17 +0000 Subject: Version 2.1.11 --- docs/topics/release-notes.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 66d6f7f3..a9083bb4 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,6 +6,12 @@ ## 2.1.x series +### 2.1.11 + +**Date**: 17th Dec 2012 + +* Bugfix: Fix issue with M2M fields in browseable API. + ### 2.1.10 **Date**: 17th Dec 2012 -- cgit v1.2.3 From 24581faceb65d78acecd253808581a5534862d08 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 18 Dec 2012 18:23:28 +0000 Subject: Update release notes. --- docs/topics/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index a9083bb4..87aaefbd 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,6 +6,10 @@ ## 2.1.x series +### Master + +* Bugfix: Fix issue where pk was was being set to a string if set by URL kwarg. + ### 2.1.11 **Date**: 17th Dec 2012 -- cgit v1.2.3 From c29b08ad43c8de5f295176eaf0270427f3a737f3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 19 Dec 2012 22:06:38 +0000 Subject: Update release notes --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 87aaefbd..c75f0879 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -8,6 +8,7 @@ ### Master +* Bugfix: Fix exception in browseable API on DELETE. * Bugfix: Fix issue where pk was was being set to a string if set by URL kwarg. ### 2.1.11 -- cgit v1.2.3 From 566b9ff27b93dfa089d054552a94d930e3f17c67 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 19 Dec 2012 22:41:00 +0000 Subject: Added @joual - Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index c169fd74..fa378cb2 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -79,6 +79,7 @@ The following people have helped make REST framework great. * Colin Murtaugh - [cmurtaugh] * Simon Pantzare - [pilt] * Szymon Teżewski - [sunscrapers] +* Joel Marcotte - [joual] Many thanks to everyone who's contributed to the project. @@ -193,3 +194,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [cmurtaugh]: https://github.com/cmurtaugh [pilt]: https://github.com/pilt [sunscrapers]: https://github.com/sunscrapers +[joual]: https://github.com/joual -- cgit v1.2.3 From c097bcef586da4513d1d6f357d9eb3d7b4b0fffb Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 19 Dec 2012 22:42:11 +0000 Subject: Update release notes. --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index c75f0879..741d908c 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -8,6 +8,7 @@ ### Master +* Bugfix: Fix bug that could occur using ChoiceField. * Bugfix: Fix exception in browseable API on DELETE. * Bugfix: Fix issue where pk was was being set to a string if set by URL kwarg. -- cgit v1.2.3 From fb4bbf7d985be21511b412011fb949182bc1b73e Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 21 Dec 2012 09:17:33 +0000 Subject: Added @treyhunner. Thank you! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index fa378cb2..8b8cac1a 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -80,6 +80,7 @@ The following people have helped make REST framework great. * Simon Pantzare - [pilt] * Szymon Teżewski - [sunscrapers] * Joel Marcotte - [joual] +* Trey Hunner - [treyhunner] Many thanks to everyone who's contributed to the project. @@ -195,3 +196,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [pilt]: https://github.com/pilt [sunscrapers]: https://github.com/sunscrapers [joual]: https://github.com/joual +[treyhunner]: https://github.com/treyhunner -- cgit v1.2.3 From 79aea2f0d082f17e7bb75cc32bd71b5f04836d43 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 21 Dec 2012 09:18:35 +0000 Subject: Version 2.1.12 --- docs/topics/release-notes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 741d908c..6dedc3d2 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,7 +6,9 @@ ## 2.1.x series -### Master +### 2.1.12 + +**Date**: 21st Dec 2012 * Bugfix: Fix bug that could occur using ChoiceField. * Bugfix: Fix exception in browseable API on DELETE. -- cgit v1.2.3 From 5f9ecd1c7ad2f52ad5711d2a89bb1884f5b662f9 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 21 Dec 2012 10:42:40 +0100 Subject: slug_kwarg attribute doesn't work; it should be slug_url_kwarg --- docs/api-guide/generic-views.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 428323b8..27c7d3f6 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -7,11 +7,11 @@ > > — [Django Documentation][cite] -One of the key benefits of class based views is the way they allow you to compose bits of reusable behaviour. REST framework takes advantage of this by providing a number of pre-built views that provide for commonly used patterns. +One of the key benefits of class based views is the way they allow you to compose bits of reusable behaviour. REST framework takes advantage of this by providing a number of pre-built views that provide for commonly used patterns. The generic views provided by REST framework allow you to quickly build API views that map closely to your database models. -If the generic views don't suit the needs of your API, you can drop down to using the regular `APIView` class, or reuse the mixins and base classes used by the generic views to compose your own set of reusable generic views. +If the generic views don't suit the needs of your API, you can drop down to using the regular `APIView` class, or reuse the mixins and base classes used by the generic views to compose your own set of reusable generic views. ## Examples @@ -29,7 +29,7 @@ For more complex cases you might also want to override various methods on the vi model = User serializer_class = UserSerializer permission_classes = (IsAdminUser,) - + def get_paginate_by(self, queryset): """ Use smaller pagination for HTML representations. @@ -150,14 +150,14 @@ Provides a base view for acting on a single object, by combining REST framework' * `queryset` - The queryset that should be used when retrieving an object from this view. If unset, defaults to the default queryset manager for `self.model`. * `pk_kwarg` - The URL kwarg that should be used to look up objects by primary key. Defaults to `'pk'`. [Can only be set to non-default on Django 1.4+] -* `slug_kwarg` - The URL kwarg that should be used to look up objects by a slug. Defaults to `'slug'`. [Can only be set to non-default on Django 1.4+] +* `slug_url_kwarg` - The URL kwarg that should be used to look up objects by a slug. Defaults to `'slug'`. [Can only be set to non-default on Django 1.4+] * `slug_field` - The field on the model that should be used to look up objects by a slug. If used, this should typically be set to a field with `unique=True`. Defaults to `'slug'`. --- # Mixins -The mixin classes provide the actions that are used to provide the basic view behaviour. Note that the mixin classes provide action methods rather than defining the handler methods such as `.get()` and `.post()` directly. This allows for more flexible composition of behaviour. +The mixin classes provide the actions that are used to provide the basic view behaviour. Note that the mixin classes provide action methods rather than defining the handler methods such as `.get()` and `.post()` directly. This allows for more flexible composition of behaviour. ## ListModelMixin @@ -220,4 +220,4 @@ Should be mixed in with [SingleObjectAPIView]. [CreateModelMixin]: #createmodelmixin [RetrieveModelMixin]: #retrievemodelmixin [UpdateModelMixin]: #updatemodelmixin -[DestroyModelMixin]: #destroymodelmixin \ No newline at end of file +[DestroyModelMixin]: #destroymodelmixin -- cgit v1.2.3 From ed09d26fb8da2391cab4b096d276028384438eb6 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sun, 23 Dec 2012 18:50:17 +0000 Subject: Update docs/topics/release-notes.md --- docs/topics/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 6dedc3d2..71fa3c03 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -6,6 +6,10 @@ ## 2.1.x series +### Master + +* Bugfix: Related fields now respect the required flag, and may be required=False. + ### 2.1.12 **Date**: 21st Dec 2012 -- cgit v1.2.3 From 9cc56a97b55e183d8131665d1409649379a969f0 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 27 Dec 2012 17:35:21 +0000 Subject: Added @akinfold for staticfiles changes. --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 8b8cac1a..e4b8da4c 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -81,6 +81,7 @@ The following people have helped make REST framework great. * Szymon Teżewski - [sunscrapers] * Joel Marcotte - [joual] * Trey Hunner - [treyhunner] +* Roman Akinfold - [akinfold] Many thanks to everyone who's contributed to the project. @@ -197,3 +198,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [sunscrapers]: https://github.com/sunscrapers [joual]: https://github.com/joual [treyhunner]: https://github.com/treyhunner +[akinfold]: https://github.com/akinfold -- cgit v1.2.3 From 4b32cda5a8a32bf43e80dfbe6d9d17a07b20152c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 27 Dec 2012 17:53:07 +0000 Subject: Update release notes and documentation for 2.2.0 --- docs/index.md | 19 +++++++++++++++---- docs/topics/release-notes.md | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/index.md b/docs/index.md index cc0f2a13..5d90e9e5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,7 +15,7 @@ Django REST framework is a lightweight library that makes it easy to build Web A Web APIs built using REST framework are fully self-describing and web browseable - a huge useability win for your developers. It also supports a wide range of media types, authentication and permission policies out of the box. -If you are considering using REST framework for your API, we recommend reading the [REST framework 2 announcment][rest-framework-2-announcement] which gives a good overview of the framework and it's capabilities. +If you are considering using REST framework for your API, we recommend reading the [REST framework 2 announcement][rest-framework-2-announcement] which gives a good overview of the framework and it's capabilities. There is also a sandbox API you can use for testing purposes, [available here][sandbox]. @@ -52,21 +52,32 @@ Install using `pip`, including any optional packages you want... pip install -r requirements.txt pip install -r optionals.txt -Add `rest_framework` to your `INSTALLED_APPS`. +Add `'rest_framework'` to your `INSTALLED_APPS` setting. INSTALLED_APPS = ( ... 'rest_framework', ) -If you're intending to use the browseable API you'll want to add REST framework's login and logout views. Add the following to your root `urls.py` file. +### Browseable API requirements + +If you're intending to use the browseable API you'll also want to also ensure you include `'django.contrib.staticfiles'` in your `INSTALLED_APPS` setting. + + INSTALLED_APPS = ( + ... + 'django.contrib.staticfiles', + 'rest_framework', + ) + +You'll proabably also want to add REST framework's login and logout views. +Add the following to your root `urls.py` file. urlpatterns = patterns('', ... url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ) -Note that the URL path can be whatever you want, but you must include `rest_framework.urls` with the `rest_framework` namespace. +Note that the URL path can be whatever you want, but you must include `'rest_framework.urls'` with the `'rest_framework'` namespace. ## Quickstart diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 71fa3c03..1934292c 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -4,12 +4,27 @@ > > — Eric S. Raymond, [The Cathedral and the Bazaar][cite]. -## 2.1.x series +## Versioning + +Minor version numbers (0.0.x) are used for changes that are API compatible. You should be able to upgrade between minor point releases without any other code changes. + +Medium version numbers (0.x.0) may include minor API changes. You should read the release notes carefully before upgrading between medium point releases. -### Master +## 2.2.x series +### 2.2.0 + +**Date**: 27th Dec 2012 + +* Support configurable `STATICFILES_STORAGE` storage. * Bugfix: Related fields now respect the required flag, and may be required=False. +**API-incompatible changes**: From 2.2.0 Onwards you must make sure to include `'django.contrib.staticfiles'` in your `INSTALLED_APPS`. This is in line with Django's 1.4's recommended usage of [the `'staticfiles'` template tag][staticfiles14] instead of Django 1.3's recommended usage of [the `'static'` template tag][staticfiles13]. + +--- + +## 2.1.x series + ### 2.1.12 **Date**: 21st Dec 2012 @@ -105,7 +120,7 @@ * Support use of HTML exception templates. Eg. `403.html` * Hyperlinked fields take optional `slug_field`, `slug_url_kwarg` and `pk_url_kwarg` arguments. -* Bugfix: Deal with optional trailing slashs properly when generating breadcrumbs. +* Bugfix: Deal with optional trailing slashes properly when generating breadcrumbs. * Bugfix: Make textareas same width as other fields in browsable API. * Private API change: `.get_serializer` now uses same `instance` and `data` ordering as serializer initialization. @@ -113,8 +128,6 @@ **Date**: 5th Nov 2012 -**Warning**: Please read [this thread][2.1.0-notes] regarding the `instance` and `data` keyword args before updating to 2.1.0. - * **Serializer `instance` and `data` keyword args have their position swapped.** * `queryset` argument is now optional on writable model fields. * Hyperlinked related fields optionally take `slug_field` and `slug_url_kwarg` arguments. @@ -123,6 +136,8 @@ * Bugfix: Support choice field in Browseable API. * Bugfix: Related fields with `read_only=True` do not require a `queryset` argument. +**API-incompatible changes**: Please read [this thread][2.1.0-notes] regarding the `instance` and `data` keyword args before updating to 2.1.0. + --- ## 2.0.x series @@ -159,9 +174,9 @@ * Allow views to specify template used by TemplateRenderer * More consistent error responses * Some serializer fixes -* Fix internet explorer ajax behaviour +* Fix internet explorer ajax behavior * Minor xml and yaml fixes -* Improve setup (eg use staticfiles, not the defunct ADMIN_MEDIA_PREFIX) +* Improve setup (e.g. use staticfiles, not the defunct ADMIN_MEDIA_PREFIX) * Sensible absolute URL generation, not using hacky set_script_prefix --- @@ -172,13 +187,13 @@ * Added DjangoModelPermissions class to support `django.contrib.auth` style permissions. * Use `staticfiles` for css files. - - Easier to override. Won't conflict with customised admin styles (eg grappelli) + - Easier to override. Won't conflict with customized admin styles (e.g. grappelli) * Templates are now nicely namespaced. - Allows easier overriding. * Drop implied 'pk' filter if last arg in urlconf is unnamed. - - Too magical. Explict is better than implicit. -* Saner template variable autoescaping. -* Tider setup.py + - Too magical. Explicit is better than implicit. +* Saner template variable auto-escaping. +* Tidier setup.py * Updated for URLObject 2.0 * Bugfixes: - Bug with PerUserThrottling when user contains unicode chars. @@ -266,5 +281,7 @@ * Initial release. [cite]: http://www.catb.org/~esr/writings/cathedral-bazaar/cathedral-bazaar/ar01s04.html +[staticfiles14]: https://docs.djangoproject.com/en/1.4/howto/static-files/#with-a-template-tag +[staticfiles13]: https://docs.djangoproject.com/en/1.3/howto/static-files/#with-a-template-tag [2.1.0-notes]: https://groups.google.com/d/topic/django-rest-framework/Vv2M0CMY9bg/discussion [announcement]: rest-framework-2-announcement.md -- cgit v1.2.3 From 3e4242fc43def87fc6e0bda11afd8d3a82bd3ae3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 28 Dec 2012 12:33:24 +0000 Subject: django.contrib.staticfiles no longer needs to be in INSTALLED_APPS --- docs/index.md | 13 +------------ docs/topics/release-notes.md | 16 +++++++--------- 2 files changed, 8 insertions(+), 21 deletions(-) (limited to 'docs') diff --git a/docs/index.md b/docs/index.md index 5d90e9e5..69d972d0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -59,18 +59,7 @@ Add `'rest_framework'` to your `INSTALLED_APPS` setting. 'rest_framework', ) -### Browseable API requirements - -If you're intending to use the browseable API you'll also want to also ensure you include `'django.contrib.staticfiles'` in your `INSTALLED_APPS` setting. - - INSTALLED_APPS = ( - ... - 'django.contrib.staticfiles', - 'rest_framework', - ) - -You'll proabably also want to add REST framework's login and logout views. -Add the following to your root `urls.py` file. +If you're intending to use the browseable API you'll probably also want to add REST framework's login and logout views. Add the following to your root `urls.py` file. urlpatterns = patterns('', ... diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 1934292c..0a17f1a6 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -10,20 +10,18 @@ Minor version numbers (0.0.x) are used for changes that are API compatible. You Medium version numbers (0.x.0) may include minor API changes. You should read the release notes carefully before upgrading between medium point releases. -## 2.2.x series +Major version numbers (x.0.0) are reserved for project milestones. No major point releases are currently planned. -### 2.2.0 +--- -**Date**: 27th Dec 2012 +## 2.1.x series -* Support configurable `STATICFILES_STORAGE` storage. -* Bugfix: Related fields now respect the required flag, and may be required=False. +### 2.1.13 -**API-incompatible changes**: From 2.2.0 Onwards you must make sure to include `'django.contrib.staticfiles'` in your `INSTALLED_APPS`. This is in line with Django's 1.4's recommended usage of [the `'staticfiles'` template tag][staticfiles14] instead of Django 1.3's recommended usage of [the `'static'` template tag][staticfiles13]. +**Date**: 28th Dec 2012 ---- - -## 2.1.x series +* Support configurable `STATICFILES_STORAGE` storage. +* Bugfix: Related fields now respect the required flag, and may be required=False. ### 2.1.12 -- cgit v1.2.3 From 5d4ea3d23fdb173b4109a64b2d4231d93d394387 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 28 Dec 2012 12:59:24 +0000 Subject: Add .validate() example --- docs/api-guide/serializers.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 19efde3c..da1efb8f 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -110,7 +110,22 @@ Your `validate_` methods should either just return the `attrs` dictio ### Object-level validation -To do any other validation that requires access to multiple fields, add a method called `.validate()` to your `Serializer` subclass. This method takes a single argument, which is the `attrs` dictionary. It should raise a `ValidationError` if necessary, or just return `attrs`. +To do any other validation that requires access to multiple fields, add a method called `.validate()` to your `Serializer` subclass. This method takes a single argument, which is the `attrs` dictionary. It should raise a `ValidationError` if necessary, or just return `attrs`. For example: + + from rest_framework import serializers + + class EventSerializer(serializers.Serializer): + description = serializers.CahrField(max_length=100) + start = serializers.DateTimeField() + finish = serializers.DateTimeField() + + def validate(self, attrs): + """ + Check that the start is before the stop. + """ + if attrs['start'] < attrs['finish']: + raise serializers.ValidationError("finish must occur after start") + return attrs ## Saving object state -- cgit v1.2.3 From 1f6af163fece28db3ba7943edce2415a23874d44 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 29 Dec 2012 12:15:15 +0000 Subject: Tweak quote --- docs/api-guide/serializers.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index da1efb8f..d98a602f 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -4,8 +4,7 @@ > Expanding the usefulness of the serializers is something that we would like to address. However, it's not a trivial problem, and it -will take some serious design work. Any offers to help out in this -area would be gratefully accepted. +will take some serious design work. > > — Russell Keith-Magee, [Django users group][cite] -- cgit v1.2.3 From 923f81d26971510c12cb08e3061c7b37c0c6ffe8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 29 Dec 2012 13:19:05 +0000 Subject: Nested serializers now support nullable relationships, plus test. Fixes #384 --- docs/topics/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 0a17f1a6..dd54a613 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -16,6 +16,10 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ## 2.1.x series +### Master + +* Bugfix: Nested serializers now support nullable relationships. + ### 2.1.13 **Date**: 28th Dec 2012 -- cgit v1.2.3 From 25398e8cf1b3c6e5f959c2f8063c9bcfc3b377c7 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 29 Dec 2012 13:32:56 +0000 Subject: Update release notes --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index dd54a613..f5d0fa07 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -18,6 +18,7 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ### Master +* Bugfix: Model fields with `blank=True` are now `required=False` by default. * Bugfix: Nested serializers now support nullable relationships. ### 2.1.13 -- cgit v1.2.3 From 3c7a63619900b92e9d642a7c3c048f9132b74cd4 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 29 Dec 2012 16:58:51 +0000 Subject: Updated release notes --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index f5d0fa07..3ca3e6b3 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -18,6 +18,7 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ### Master +* Bugfix: ModelSerializers now include reverse FK fields on creation. * Bugfix: Model fields with `blank=True` are now `required=False` by default. * Bugfix: Nested serializers now support nullable relationships. -- cgit v1.2.3 From 275fcde5e6f79e30b44e3f4e620b0328a0692532 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 29 Dec 2012 16:59:01 +0000 Subject: Added @toranb - Thank you! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index e4b8da4c..eafea6d4 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -82,6 +82,7 @@ The following people have helped make REST framework great. * Joel Marcotte - [joual] * Trey Hunner - [treyhunner] * Roman Akinfold - [akinfold] +* Toran Billups - [toranb] Many thanks to everyone who's contributed to the project. @@ -199,3 +200,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [joual]: https://github.com/joual [treyhunner]: https://github.com/treyhunner [akinfold]: https://github.com/akinfold +[toranb]: https://github.com/toranb -- cgit v1.2.3 From af5c3c3bf4645fa9cb1d7c4d17c0f3a530040df8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sun, 30 Dec 2012 07:51:07 +0000 Subject: Added @sebastibe. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index eafea6d4..c4277a23 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -83,6 +83,7 @@ The following people have helped make REST framework great. * Trey Hunner - [treyhunner] * Roman Akinfold - [akinfold] * Toran Billups - [toranb] +* Sébastien Béal - [sebastibe] Many thanks to everyone who's contributed to the project. @@ -201,3 +202,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [treyhunner]: https://github.com/treyhunner [akinfold]: https://github.com/akinfold [toranb]: https://github.com/toranb +[sebastibe]: https://github.com/sebastibe -- cgit v1.2.3 From 8fad0a727a897970531a087346ecd44f361b25f4 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 31 Dec 2012 08:53:40 +0000 Subject: Relation fields move into relations.py --- docs/api-guide/fields.md | 179 +++++++------------------------------------- docs/api-guide/relations.md | 139 ++++++++++++++++++++++++++++++++++ docs/index.md | 2 + docs/template.html | 1 + 4 files changed, 169 insertions(+), 152 deletions(-) create mode 100644 docs/api-guide/relations.md (limited to 'docs') diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 50a09701..5bc8f7f7 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -2,11 +2,11 @@ # Serializer fields -> Flat is better than nested. +> Each field in a Form class is responsible not only for validating data, but also for "cleaning" it -- normalizing it to a consistent format. > -> — [The Zen of Python][cite] +> — [Django documentation][cite] -Serializer fields handle converting between primative values and internal datatypes. They also deal with validating input values, as well as retrieving and setting the values from their parent objects. +Serializer fields handle converting between primitive values and internal datatypes. They also deal with validating input values, as well as retrieving and setting the values from their parent objects. --- @@ -28,7 +28,7 @@ Defaults to the name of the field. ### `read_only` -Set this to `True` to ensure that the field is used when serializing a representation, but is not used when updating an instance dureing deserialization. +Set this to `True` to ensure that the field is used when serializing a representation, but is not used when updating an instance during deserialization. Defaults to `False` @@ -41,7 +41,7 @@ Defaults to `True`. ### `default` -If set, this gives the default value that will be used for the field if none is supplied. If not set the default behaviour is to not populate the attribute at all. +If set, this gives the default value that will be used for the field if none is supplied. If not set the default behavior is to not populate the attribute at all. ### `validators` @@ -96,9 +96,9 @@ Would produce output similar to: 'expired': True } -By default, the `Field` class will perform a basic translation of the source value into primative datatypes, falling back to unicode representations of complex datatypes when necessary. +By default, the `Field` class will perform a basic translation of the source value into primitive datatypes, falling back to unicode representations of complex datatypes when necessary. -You can customize this behaviour by overriding the `.to_native(self, value)` method. +You can customize this behavior by overriding the `.to_native(self, value)` method. ## WritableField @@ -110,6 +110,24 @@ A generic field that can be tied to any arbitrary model field. The `ModelField` **Signature:** `ModelField(model_field=)` +## SerializerMethodField + +This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. For example: + + from rest_framework import serializers + from django.contrib.auth.models import User + from django.utils.timezone import now + + class UserSerializer(serializers.ModelSerializer): + + days_since_joined = serializers.SerializerMethodField('get_days_since_joined') + + class Meta: + model = User + + def get_days_since_joined(self, obj): + return (now() - obj.date_joined).days + --- # Typed Fields @@ -211,151 +229,8 @@ Signature and validation is the same as with `FileField`. --- -**Note:** `FileFields` and `ImageFields` are only suitable for use with MultiPartParser, since eg json doesn't support file uploads. +**Note:** `FileFields` and `ImageFields` are only suitable for use with MultiPartParser, since e.g. json doesn't support file uploads. Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files. ---- - -# Relational Fields - -Relational fields are used to represent model relationships. They can be applied to `ForeignKey`, `ManyToManyField` and `OneToOneField` relationships, as well as to reverse relationships, and custom relationships such as `GenericForeignKey`. - -## RelatedField - -This field can be applied to any of the following: - -* A `ForeignKey` field. -* A `OneToOneField` field. -* A reverse OneToOne relationship -* Any other "to-one" relationship. - -By default `RelatedField` will represent the target of the field using it's `__unicode__` method. - -You can customise this behaviour by subclassing `ManyRelatedField`, and overriding the `.to_native(self, value)` method. - -## ManyRelatedField - -This field can be applied to any of the following: - -* A `ManyToManyField` field. -* A reverse ManyToMany relationship. -* A reverse ForeignKey relationship -* Any other "to-many" relationship. - -By default `ManyRelatedField` will represent the targets of the field using their `__unicode__` method. - -For example, given the following models: - - class TaggedItem(models.Model): - """ - Tags arbitrary model instances using a generic relation. - - See: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/ - """ - tag = models.SlugField() - content_type = models.ForeignKey(ContentType) - object_id = models.PositiveIntegerField() - content_object = GenericForeignKey('content_type', 'object_id') - - def __unicode__(self): - return self.tag - - - class Bookmark(models.Model): - """ - A bookmark consists of a URL, and 0 or more descriptive tags. - """ - url = models.URLField() - tags = GenericRelation(TaggedItem) - -And a model serializer defined like this: - - class BookmarkSerializer(serializers.ModelSerializer): - tags = serializers.ManyRelatedField(source='tags') - - class Meta: - model = Bookmark - exclude = ('id',) - -Then an example output format for a Bookmark instance would be: - - { - 'tags': [u'django', u'python'], - 'url': u'https://www.djangoproject.com/' - } - -## PrimaryKeyRelatedField / ManyPrimaryKeyRelatedField - -`PrimaryKeyRelatedField` and `ManyPrimaryKeyRelatedField` will represent the target of the relationship using it's primary key. - -By default these fields are read-write, although you can change this behaviour using the `read_only` flag. - -**Arguments**: - -* `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. -* `null` - If set to `True`, the field will accept values of `None` or the emptystring for nullable relationships. - -## SlugRelatedField / ManySlugRelatedField - -`SlugRelatedField` and `ManySlugRelatedField` will represent the target of the relationship using a unique slug. - -By default these fields read-write, although you can change this behaviour using the `read_only` flag. - -**Arguments**: - -* `slug_field` - The field on the target that should be used to represent it. This should be a field that uniquely identifies any given instance. For example, `username`. -* `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. -* `null` - If set to `True`, the field will accept values of `None` or the emptystring for nullable relationships. - -## HyperlinkedRelatedField / ManyHyperlinkedRelatedField - -`HyperlinkedRelatedField` and `ManyHyperlinkedRelatedField` will represent the target of the relationship using a hyperlink. - -By default, `HyperlinkedRelatedField` is read-write, although you can change this behaviour using the `read_only` flag. - -**Arguments**: - -* `view_name` - The view name that should be used as the target of the relationship. **required**. -* `format` - If using format suffixes, hyperlinked fields will use the same format suffix for the target unless overridden by using the `format` argument. -* `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. -* `slug_field` - The field on the target that should be used for the lookup. Default is `'slug'`. -* `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. -* `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. -* `null` - If set to `True`, the field will accept values of `None` or the emptystring for nullable relationships. - -## HyperLinkedIdentityField - -This field can be applied as an identity relationship, such as the `'url'` field on a HyperlinkedModelSerializer. - -This field is always read-only. - -**Arguments**: - -* `view_name` - The view name that should be used as the target of the relationship. **required**. -* `format` - If using format suffixes, hyperlinked fields will use the same format suffix for the target unless overridden by using the `format` argument. -* `slug_field` - The field on the target that should be used for the lookup. Default is `'slug'`. -* `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. -* `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. - -# Other Fields - -## SerializerMethodField - -This is a read-only field. It gets its value by calling a method on the serializer class it is attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. For example: - - from rest_framework import serializers - from django.contrib.auth.models import User - from django.utils.timezone import now - - class UserSerializer(serializers.ModelSerializer): - - days_since_joined = serializers.SerializerMethodField('get_days_since_joined') - - class Meta: - model = User - - def get_days_since_joined(self, obj): - return (now() - obj.date_joined).days - -[cite]: http://www.python.org/dev/peps/pep-0020/ +[cite]: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data [FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS diff --git a/docs/api-guide/relations.md b/docs/api-guide/relations.md new file mode 100644 index 00000000..351b5e09 --- /dev/null +++ b/docs/api-guide/relations.md @@ -0,0 +1,139 @@ + + +# Serializer relations + +> Bad programmers worry about the code. +> Good programmers worry about data structures and their relationships. +> +> — [Linus Torvalds][cite] + + +Relational fields are used to represent model relationships. They can be applied to `ForeignKey`, `ManyToManyField` and `OneToOneField` relationships, as well as to reverse relationships, and custom relationships such as `GenericForeignKey`. + +--- + +**Note:** The relational fields are declared in `relations.py`, but by convention you should import them using `from rest_framework import serializers` and refer to fields as `serializers.`. + +--- + +## RelatedField + +This field can be applied to any of the following: + +* A `ForeignKey` field. +* A `OneToOneField` field. +* A reverse OneToOne relationship +* Any other "to-one" relationship. + +By default `RelatedField` will represent the target of the field using it's `__unicode__` method. + +You can customize this behavior by subclassing `ManyRelatedField`, and overriding the `.to_native(self, value)` method. + +## ManyRelatedField + +This field can be applied to any of the following: + +* A `ManyToManyField` field. +* A reverse ManyToMany relationship. +* A reverse ForeignKey relationship +* Any other "to-many" relationship. + +By default `ManyRelatedField` will represent the targets of the field using their `__unicode__` method. + +For example, given the following models: + + class TaggedItem(models.Model): + """ + Tags arbitrary model instances using a generic relation. + + See: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/ + """ + tag = models.SlugField() + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + content_object = GenericForeignKey('content_type', 'object_id') + + def __unicode__(self): + return self.tag + + + class Bookmark(models.Model): + """ + A bookmark consists of a URL, and 0 or more descriptive tags. + """ + url = models.URLField() + tags = GenericRelation(TaggedItem) + +And a model serializer defined like this: + + class BookmarkSerializer(serializers.ModelSerializer): + tags = serializers.ManyRelatedField(source='tags') + + class Meta: + model = Bookmark + exclude = ('id',) + +Then an example output format for a Bookmark instance would be: + + { + 'tags': [u'django', u'python'], + 'url': u'https://www.djangoproject.com/' + } + +## PrimaryKeyRelatedField +## ManyPrimaryKeyRelatedField + +`PrimaryKeyRelatedField` and `ManyPrimaryKeyRelatedField` will represent the target of the relationship using it's primary key. + +By default these fields are read-write, although you can change this behavior using the `read_only` flag. + +**Arguments**: + +* `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. +* `null` - If set to `True`, the field will accept values of `None` or the empty-string for nullable relationships. + +## SlugRelatedField +## ManySlugRelatedField + +`SlugRelatedField` and `ManySlugRelatedField` will represent the target of the relationship using a unique slug. + +By default these fields read-write, although you can change this behavior using the `read_only` flag. + +**Arguments**: + +* `slug_field` - The field on the target that should be used to represent it. This should be a field that uniquely identifies any given instance. For example, `username`. +* `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. +* `null` - If set to `True`, the field will accept values of `None` or the empty-string for nullable relationships. + +## HyperlinkedRelatedField +## ManyHyperlinkedRelatedField + +`HyperlinkedRelatedField` and `ManyHyperlinkedRelatedField` will represent the target of the relationship using a hyperlink. + +By default, `HyperlinkedRelatedField` is read-write, although you can change this behavior using the `read_only` flag. + +**Arguments**: + +* `view_name` - The view name that should be used as the target of the relationship. **required**. +* `format` - If using format suffixes, hyperlinked fields will use the same format suffix for the target unless overridden by using the `format` argument. +* `queryset` - By default `ModelSerializer` classes will use the default queryset for the relationship. `Serializer` classes must either set a queryset explicitly, or set `read_only=True`. +* `slug_field` - The field on the target that should be used for the lookup. Default is `'slug'`. +* `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. +* `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. +* `null` - If set to `True`, the field will accept values of `None` or the empty-string for nullable relationships. + +## HyperLinkedIdentityField + +This field can be applied as an identity relationship, such as the `'url'` field on a HyperlinkedModelSerializer. + +This field is always read-only. + +**Arguments**: + +* `view_name` - The view name that should be used as the target of the relationship. **required**. +* `format` - If using format suffixes, hyperlinked fields will use the same format suffix for the target unless overridden by using the `format` argument. +* `slug_field` - The field on the target that should be used for the lookup. Default is `'slug'`. +* `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. +* `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. + +[cite]: http://lwn.net/Articles/193245/ diff --git a/docs/index.md b/docs/index.md index 69d972d0..4d50e5d6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -94,6 +94,7 @@ The API guide is your complete reference manual to all the functionality provide * [Renderers][renderers] * [Serializers][serializers] * [Serializer fields][fields] +* [Serializer relations][relations] * [Authentication][authentication] * [Permissions][permissions] * [Throttling][throttling] @@ -185,6 +186,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [renderers]: api-guide/renderers.md [serializers]: api-guide/serializers.md [fields]: api-guide/fields.md +[relations]: api-guide/relations.md [authentication]: api-guide/authentication.md [permissions]: api-guide/permissions.md [throttling]: api-guide/throttling.md diff --git a/docs/template.html b/docs/template.html index 676a4807..d789cc58 100644 --- a/docs/template.html +++ b/docs/template.html @@ -72,6 +72,7 @@
  • Renderers
  • Serializers
  • Serializer fields
  • +
  • Serializer relations
  • Authentication
  • Permissions
  • Throttling
  • -- cgit v1.2.3 From eff833b39d2f41c9eb773214f5b45c3d991e1511 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 31 Dec 2012 08:53:49 +0000 Subject: Version 2.1.14 --- docs/topics/release-notes.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 3ca3e6b3..c93eebac 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -16,12 +16,19 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ## 2.1.x series -### Master +### 2.1.14 + +**Date**: 31st Dec 2012 * Bugfix: ModelSerializers now include reverse FK fields on creation. * Bugfix: Model fields with `blank=True` are now `required=False` by default. * Bugfix: Nested serializers now support nullable relationships. +**Note**: From 2.1.14 onwards, relational fields move out of the `fields.py` module and into the new `relations.py` module, in order to seperate them from regular data type fields, such as `CharField` and `IntegerField`. + +This change will not affect user code, so long as it's following the recommended import style of `from rest_framework import serializers` and refering to fields using the style `serializers.PrimaryKeyRelatedField`. + + ### 2.1.13 **Date**: 28th Dec 2012 -- cgit v1.2.3 From f62acf025e938d14b1e74d3cecb4f42975793e9a Mon Sep 17 00:00:00 2001 From: Mark Aaron Shirley Date: Tue, 1 Jan 2013 18:06:22 +0100 Subject: Update release notes --- docs/topics/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index c93eebac..5b34bf3d 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -16,6 +16,10 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ## 2.1.x series +### Master + +* Relation changes are no longer persisted in `.restore_object` + ### 2.1.14 **Date**: 31st Dec 2012 -- cgit v1.2.3 From 161432d78c29dd607fb9b16957aaa00010027fcd Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 2 Jan 2013 13:49:43 +0000 Subject: Added @ahankinson, for PATCH support. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index c4277a23..008e4a1b 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -84,6 +84,7 @@ The following people have helped make REST framework great. * Roman Akinfold - [akinfold] * Toran Billups - [toranb] * Sébastien Béal - [sebastibe] +* Andrew Hankinson - [ahankinson] Many thanks to everyone who's contributed to the project. @@ -203,3 +204,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [akinfold]: https://github.com/akinfold [toranb]: https://github.com/toranb [sebastibe]: https://github.com/sebastibe +[ahankinson]: https://github.com/ahankinson -- cgit v1.2.3 From 097f4c6962330c0fd550a9c7ada8344472e0a443 Mon Sep 17 00:00:00 2001 From: Yuri Prezument Date: Thu, 3 Jan 2013 09:40:49 +0200 Subject: Updated release-notes --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index e4bd1217..0e206809 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -21,6 +21,7 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi * Added `PATCH` support. * Added `RetrieveUpdateAPIView`. * Relation changes are now persisted in `save` instead of in `.restore_object`. +* Bugfix: Fix issue with FileField validation with files=None. ### 2.1.14 -- cgit v1.2.3 From 05c72a5d303490270c9d56b81964ee59fc1ab253 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 3 Jan 2013 21:43:54 +0000 Subject: Fix copyright notice and travis badge --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/index.md b/docs/index.md index 4d50e5d6..080eca6f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -138,7 +138,7 @@ Paid support is also available from [DabApps], and can include work on REST fram ## License -Copyright (c) 2011-2012, Tom Christie +Copyright (c) 2011-2013, Tom Christie All rights reserved. Redistribution and use in source and binary forms, with or without @@ -162,7 +162,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [travis]: http://travis-ci.org/tomchristie/django-rest-framework?branch=master -[travis-build-image]: https://secure.travis-ci.org/tomchristie/django-rest-framework.png?branch=restframework2 +[travis-build-image]: https://secure.travis-ci.org/tomchristie/django-rest-framework.png?branch=master [urlobject]: https://github.com/zacharyvoase/urlobject [markdown]: http://pypi.python.org/pypi/Markdown/ [yaml]: http://pypi.python.org/pypi/PyYAML -- cgit v1.2.3 From 92ae08207a7d588aef05eecf6826765ac6caf299 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 3 Jan 2013 21:44:18 +0000 Subject: Drop unused private save_m2m flag --- docs/topics/release-notes.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 0e206809..b0100179 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -21,6 +21,8 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi * Added `PATCH` support. * Added `RetrieveUpdateAPIView`. * Relation changes are now persisted in `save` instead of in `.restore_object`. +* Cleanup unused internal `save_m2m` flag on `ModelSerializer.save()`. +* Relation changes are now persisted in `.save()` instead of in `.restore_object()`. * Bugfix: Fix issue with FileField validation with files=None. ### 2.1.14 -- cgit v1.2.3 From bfea7f64ee66cf96c6802ab68d03983aa5bf997f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 3 Jan 2013 21:46:18 +0000 Subject: Tweak behavior of hyperlinked fields that include an explicit format suffix. --- docs/topics/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index b0100179..b5d5ae02 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -66,7 +66,7 @@ This change will not affect user code, so long as it's following the recommended * Bugfix: Ensure read-only fields don't have model validation applied. * Bugfix: Fix hyperlinked fields in paginated results. -## 2.1.9 +### 2.1.9 **Date**: 11th Dec 2012 -- cgit v1.2.3 From a122856d4610492670838298e40a2081f5ef9f75 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 3 Jan 2013 21:50:28 +0000 Subject: Tweak behavior of hyperlinked fields with an explicit format suffix. --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index b5d5ae02..6230d39e 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -22,6 +22,7 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi * Added `RetrieveUpdateAPIView`. * Relation changes are now persisted in `save` instead of in `.restore_object`. * Cleanup unused internal `save_m2m` flag on `ModelSerializer.save()`. +* Tweak behavior of hyperlinked fields with an explicit format suffix. * Relation changes are now persisted in `.save()` instead of in `.restore_object()`. * Bugfix: Fix issue with FileField validation with files=None. -- cgit v1.2.3 From 4223786ddcc6643bf3a3a1a100999d60c8c68060 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 3 Jan 2013 22:11:50 +0000 Subject: Tweak release notes. --- docs/topics/release-notes.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 6230d39e..eed9e1df 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -21,10 +21,11 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi * Added `PATCH` support. * Added `RetrieveUpdateAPIView`. * Relation changes are now persisted in `save` instead of in `.restore_object`. -* Cleanup unused internal `save_m2m` flag on `ModelSerializer.save()`. +* Remove unused internal `save_m2m` flag on `ModelSerializer.save()`. * Tweak behavior of hyperlinked fields with an explicit format suffix. * Relation changes are now persisted in `.save()` instead of in `.restore_object()`. -* Bugfix: Fix issue with FileField validation with files=None. +* Bugfix: Fix issue with FileField raising exception instead of validation error when files=None. +* Bugfix: Partial updates should not set default values if field is not included. ### 2.1.14 -- cgit v1.2.3 From ad671022e1a43f91e0285f53bab64b7e33395eb3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 3 Jan 2013 22:14:11 +0000 Subject: Version 2.1.15 --- docs/topics/release-notes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index eed9e1df..3b13f86f 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -16,7 +16,9 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ## 2.1.x series -### Master +### 2.1.15 + +**Date**: 3rd Jan 2013 * Added `PATCH` support. * Added `RetrieveUpdateAPIView`. -- cgit v1.2.3 From 466d4584ae64e73713a56144b6c2128e76e0f5b6 Mon Sep 17 00:00:00 2001 From: Mark Shirley Date: Thu, 3 Jan 2013 23:18:58 +0100 Subject: Remove duplicate release notes line --- docs/topics/release-notes.md | 1 - 1 file changed, 1 deletion(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 3b13f86f..c073c03b 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -22,7 +22,6 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi * Added `PATCH` support. * Added `RetrieveUpdateAPIView`. -* Relation changes are now persisted in `save` instead of in `.restore_object`. * Remove unused internal `save_m2m` flag on `ModelSerializer.save()`. * Tweak behavior of hyperlinked fields with an explicit format suffix. * Relation changes are now persisted in `.save()` instead of in `.restore_object()`. -- cgit v1.2.3 From eb14278a3b08247c0aff5b2338a98203b51728c3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 4 Jan 2013 13:50:40 +0000 Subject: Add proper validation for updating relational fields with incorrect types. Fixes #446. --- docs/topics/release-notes.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index c073c03b..40b65761 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -16,6 +16,10 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ## 2.1.x series +### Master + +* Bugfix: Validation errors instead of exceptions when related fields receive incorrect types. + ### 2.1.15 **Date**: 3rd Jan 2013 @@ -36,9 +40,9 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi * Bugfix: Model fields with `blank=True` are now `required=False` by default. * Bugfix: Nested serializers now support nullable relationships. -**Note**: From 2.1.14 onwards, relational fields move out of the `fields.py` module and into the new `relations.py` module, in order to seperate them from regular data type fields, such as `CharField` and `IntegerField`. +**Note**: From 2.1.14 onwards, relational fields move out of the `fields.py` module and into the new `relations.py` module, in order to separate them from regular data type fields, such as `CharField` and `IntegerField`. -This change will not affect user code, so long as it's following the recommended import style of `from rest_framework import serializers` and refering to fields using the style `serializers.PrimaryKeyRelatedField`. +This change will not affect user code, so long as it's following the recommended import style of `from rest_framework import serializers` and referring to fields using the style `serializers.PrimaryKeyRelatedField`. ### 2.1.13 -- cgit v1.2.3 From 26f9acb45ac0dcd1363399f518834c56d3f9984d Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 4 Jan 2013 14:11:05 +0000 Subject: Validation errors instead of exceptions when serializers receive incorrect types. Fixes #402. --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 40b65761..eff7314b 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -18,6 +18,7 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ### Master +* Bugfix: Validation errors instead of exceptions when serializers receive incorrect types. * Bugfix: Validation errors instead of exceptions when related fields receive incorrect types. ### 2.1.15 -- cgit v1.2.3 From d7f3c86ad1edec7e7d42fe75238100832f5e7f1b Mon Sep 17 00:00:00 2001 From: Yuri Prezument Date: Sat, 5 Jan 2013 17:45:55 +0200 Subject: Updated release notes --- docs/topics/release-notes.md | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index eff7314b..edd948ac 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -18,6 +18,7 @@ Major version numbers (x.0.0) are reserved for project milestones. No major poi ### Master +* Deprecate django.utils.simplejson in favor of Python 2.6's built-in json module. * Bugfix: Validation errors instead of exceptions when serializers receive incorrect types. * Bugfix: Validation errors instead of exceptions when related fields receive incorrect types. -- cgit v1.2.3 From 12bb25b372de43ac3a944a8eff518b1c6f41ddfc Mon Sep 17 00:00:00 2001 From: Yuri Prezument Date: Sat, 5 Jan 2013 17:51:33 +0200 Subject: Added @juanriaza. Thanks --- docs/topics/credits.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 008e4a1b..7da6308d 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -2,7 +2,7 @@ The following people have helped make REST framework great. -* Tom Christie - [tomchristie] +* Tom Christie - [tomchristie] * Marko Tibold - [markotibold] * Paul Bagwell - [pbgwl] * Sébastien Piquemal - [sebpiq] @@ -85,6 +85,7 @@ The following people have helped make REST framework great. * Toran Billups - [toranb] * Sébastien Béal - [sebastibe] * Andrew Hankinson - [ahankinson] +* Juan Riaza - [juanriaza] Many thanks to everyone who's contributed to the project. @@ -96,7 +97,7 @@ Project hosting is with [GitHub]. Continuous integration testing is managed with [Travis CI][travis-ci]. -The [live sandbox][sandbox] is hosted on [Heroku]. +The [live sandbox][sandbox] is hosted on [Heroku]. Various inspiration taken from the [Piston], [Tastypie] and [Dagny] projects. @@ -107,7 +108,7 @@ Development of REST framework 2.0 was sponsored by [DabApps]. For usage questions please see the [REST framework discussion group][group]. You can also contact [@_tomchristie][twitter] directly on twitter. - + [email]: mailto:tom@tomchristie.com [twitter]: http://twitter.com/_tomchristie [bootstrap]: http://twitter.github.com/bootstrap/ @@ -205,3 +206,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [toranb]: https://github.com/toranb [sebastibe]: https://github.com/sebastibe [ahankinson]: https://github.com/ahankinson +[juanriaza]: https://github.com/juanriaza -- cgit v1.2.3 From 152e6d5c0af9c55aa9c276b8270aad700c43eae3 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 7 Jan 2013 08:57:43 +0000 Subject: Added @michaelmior. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 7da6308d..252e41de 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -86,6 +86,7 @@ The following people have helped make REST framework great. * Sébastien Béal - [sebastibe] * Andrew Hankinson - [ahankinson] * Juan Riaza - [juanriaza] +* Michael Mior - [michaelmior] Many thanks to everyone who's contributed to the project. @@ -207,3 +208,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [sebastibe]: https://github.com/sebastibe [ahankinson]: https://github.com/ahankinson [juanriaza]: https://github.com/juanriaza +[michaelmior]: https://github.com/michaelmior -- cgit v1.2.3 From de00d3720ea6d4aca06c596eaee8d0d528f19f82 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 7 Jan 2013 14:55:55 +0000 Subject: Added @mjtamlyn. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 252e41de..83272766 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -87,6 +87,7 @@ The following people have helped make REST framework great. * Andrew Hankinson - [ahankinson] * Juan Riaza - [juanriaza] * Michael Mior - [michaelmior] +* Marc Tamlyn - [mjtamlyn] Many thanks to everyone who's contributed to the project. @@ -209,3 +210,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [ahankinson]: https://github.com/ahankinson [juanriaza]: https://github.com/juanriaza [michaelmior]: https://github.com/michaelmior +[mjtamlyn]: https://github.com/mjtamlyn -- cgit v1.2.3 From d9df15f32174f9ddac7135ee33c74771a3173350 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 7 Jan 2013 14:56:26 +0000 Subject: Added @juanriaza's `djangorestframework-msgpack` package to the docs. --- docs/api-guide/parsers.md | 13 +++++++++++++ docs/api-guide/renderers.md | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/parsers.md b/docs/api-guide/parsers.md index 185b616c..9356b420 100644 --- a/docs/api-guide/parsers.md +++ b/docs/api-guide/parsers.md @@ -159,4 +159,17 @@ For example: files = {name: uploaded} return DataAndFiles(data, files) +--- + +# Third party packages + +The following third party packages are also available. + +## MessagePack + +[MessagePack][messagepack] is a fast, efficient binary serialization format. [Juan Riaza][juanriaza] maintains the `djangorestframework-msgpack` package which provides MessagePack renderer and parser support for REST framework. Documentation is [available here][djangorestframework-msgpack]. + [cite]: https://groups.google.com/d/topic/django-developers/dxI4qVzrBY4/discussion +[messagepack]: https://github.com/juanriaza/django-rest-framework-msgpack +[juanriaza]: https://github.com/juanriaza +[djangorestframework-msgpack]: https://github.com/juanriaza/django-rest-framework-msgpack \ No newline at end of file diff --git a/docs/api-guide/renderers.md b/docs/api-guide/renderers.md index 374ff0ab..389dec1f 100644 --- a/docs/api-guide/renderers.md +++ b/docs/api-guide/renderers.md @@ -271,6 +271,15 @@ Exceptions raised and handled by an HTML renderer will attempt to render using o Templates will render with a `RequestContext` which includes the `status_code` and `details` keys. +--- + +# Third party packages + +The following third party packages are also available. + +## MessagePack + +[MessagePack][messagepack] is a fast, efficient binary serialization format. [Juan Riaza][juanriaza] maintains the `djangorestframework-msgpack` package which provides MessagePack renderer and parser support for REST framework. Documentation is [available here][djangorestframework-msgpack]. [cite]: https://docs.djangoproject.com/en/dev/ref/template-response/#the-rendering-process [conneg]: content-negotiation.md @@ -280,4 +289,7 @@ Templates will render with a `RequestContext` which includes the `status_code` a [quote]: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven [application/vnd.github+json]: http://developer.github.com/v3/media/ [application/vnd.collection+json]: http://www.amundsen.com/media-types/collection/ -[django-error-views]: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views \ No newline at end of file +[django-error-views]: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views +[messagepack]: https://github.com/juanriaza/django-rest-framework-msgpack +[juanriaza]: https://github.com/juanriaza +[djangorestframework-msgpack]: https://github.com/juanriaza/django-rest-framework-msgpack \ No newline at end of file -- cgit v1.2.3 From e429f702e00ed807d68e90cd6a6af2749eb0b73e Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 7 Jan 2013 20:17:52 +0000 Subject: Fix PAGINATE_BY_PARAM docs. Refs #551 --- docs/api-guide/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index 7884d096..8c87f2ca 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -106,7 +106,7 @@ The default page size to use for pagination. If set to `None`, pagination is di Default: `None` -## PAGINATE_BY_KWARG +## PAGINATE_BY_PARAM The name of a query parameter, which can be used by the client to overide the default page size to use for pagination. If set to `None`, clients may not override the default page size. -- cgit v1.2.3