aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorTom Christie2013-12-23 09:48:59 +0000
committerTom Christie2013-12-23 09:48:59 +0000
commit52686420f4bf866064ee88a15903665f14289394 (patch)
tree41ea7b0d4863092f996f63de14e678a1c74a7a3a /docs
parent9c41c007afc71c899306bcb02e40bdfc36b09146 (diff)
parent83b31e7ea298a8948e9a76c9b971845ea0052b3c (diff)
downloaddjango-rest-framework-52686420f4bf866064ee88a15903665f14289394.tar.bz2
Merge branch 'bennbollay-patch-1' into 2.4.0
Conflicts: .travis.yml docs/api-guide/routers.md rest_framework/compat.py tox.ini
Diffstat (limited to 'docs')
-rw-r--r--docs/api-guide/exceptions.md8
-rw-r--r--docs/api-guide/parsers.md6
-rw-r--r--docs/api-guide/relations.md11
-rw-r--r--docs/api-guide/renderers.md7
-rw-r--r--docs/api-guide/routers.md4
-rw-r--r--docs/topics/2.4-accouncement.md4
-rw-r--r--docs/topics/contributing.md2
-rw-r--r--docs/topics/credits.md2
-rw-r--r--docs/topics/release-notes.md15
-rw-r--r--docs/tutorial/1-serialization.md12
-rw-r--r--docs/tutorial/2-requests-and-responses.md6
-rw-r--r--docs/tutorial/4-authentication-and-permissions.md6
12 files changed, 66 insertions, 17 deletions
diff --git a/docs/api-guide/exceptions.md b/docs/api-guide/exceptions.md
index c46d415e..221df679 100644
--- a/docs/api-guide/exceptions.md
+++ b/docs/api-guide/exceptions.md
@@ -88,6 +88,14 @@ The **base class** for all exceptions raised inside REST framework.
To provide a custom exception, subclass `APIException` and set the `.status_code` and `.detail` properties on the class.
+For example, if your API relies on a third party service that may sometimes be unreachable, you might want to implement an exception for the "503 Service Unavailable" HTTP response code. You could do this like so:
+
+ from rest_framework.exceptions import APIException
+
+ class ServiceUnavailable(APIException):
+ status_code = 503
+ detail = 'Service temporarily unavailable, try again later.'
+
## ParseError
**Signature:** `ParseError(detail=None)`
diff --git a/docs/api-guide/parsers.md b/docs/api-guide/parsers.md
index 1030fcb6..72a4af64 100644
--- a/docs/api-guide/parsers.md
+++ b/docs/api-guide/parsers.md
@@ -186,9 +186,15 @@ The following third party packages are also available.
[MessagePack][messagepack] is a fast, efficient binary serialization format. [Juan Riaza][juanriaza] maintains the [djangorestframework-msgpack][djangorestframework-msgpack] package which provides MessagePack renderer and parser support for REST framework.
+## CamelCase JSON
+
+[djangorestframework-camel-case] provides camel case JSON renderers and parsers for REST framework. This allows serializers to use Python-style underscored field names, but be exposed in the API as Javascript-style camel case field names. It is maintained by [Vitaly Babiy][vbabiy].
+
[jquery-ajax]: http://api.jquery.com/jQuery.ajax/
[cite]: https://groups.google.com/d/topic/django-developers/dxI4qVzrBY4/discussion
[upload-handlers]: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#upload-handlers
[messagepack]: https://github.com/juanriaza/django-rest-framework-msgpack
[juanriaza]: https://github.com/juanriaza
+[vbabiy]: https://github.com/vbabiy
[djangorestframework-msgpack]: https://github.com/juanriaza/django-rest-framework-msgpack
+[djangorestframework-camel-case]: https://github.com/vbabiy/djangorestframework-camel-case \ No newline at end of file
diff --git a/docs/api-guide/relations.md b/docs/api-guide/relations.md
index 556429bb..1b089c54 100644
--- a/docs/api-guide/relations.md
+++ b/docs/api-guide/relations.md
@@ -442,7 +442,18 @@ In the 2.4 release, these parts of the API will be removed entirely.
For more details see the [2.2 release announcement][2.2-announcement].
+---
+
+# Third Party Packages
+
+The following third party packages are also available.
+
+## DRF Nested Routers
+
+The [drf-nested-routers package][drf-nested-routers] provides routers and relationship fields for working with nested resources.
+
[cite]: http://lwn.net/Articles/193245/
[reverse-relationships]: https://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward
[generic-relations]: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1
[2.2-announcement]: ../topics/2.2-announcement.md
+[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
diff --git a/docs/api-guide/renderers.md b/docs/api-guide/renderers.md
index cf200569..7798827b 100644
--- a/docs/api-guide/renderers.md
+++ b/docs/api-guide/renderers.md
@@ -419,6 +419,11 @@ Comma-separated values are a plain-text tabular data format, that can be easily
[UltraJSON][ultrajson] is an optimized C JSON encoder which can give significantly faster JSON rendering. [Jacob Haslehurst][hzy] maintains the [drf-ujson-renderer][drf-ujson-renderer] package which implements JSON rendering using the UJSON package.
+## CamelCase JSON
+
+[djangorestframework-camel-case] provides camel case JSON renderers and parsers for REST framework. This allows serializers to use Python-style underscored field names, but be exposed in the API as Javascript-style camel case field names. It is maintained by [Vitaly Babiy][vbabiy].
+
+
[cite]: https://docs.djangoproject.com/en/dev/ref/template-response/#the-rendering-process
[conneg]: content-negotiation.md
[browser-accept-headers]: http://www.gethifi.com/blog/browser-rest-http-accept-headers
@@ -435,8 +440,10 @@ Comma-separated values are a plain-text tabular data format, that can be easily
[messagepack]: http://msgpack.org/
[juanriaza]: https://github.com/juanriaza
[mjumbewu]: https://github.com/mjumbewu
+[vbabiy]: https://github.com/vbabiy
[djangorestframework-msgpack]: https://github.com/juanriaza/django-rest-framework-msgpack
[djangorestframework-csv]: https://github.com/mjumbewu/django-rest-framework-csv
[ultrajson]: https://github.com/esnme/ultrajson
[hzy]: https://github.com/hzy
[drf-ujson-renderer]: https://github.com/gizmag/drf-ujson-renderer
+[djangorestframework-camel-case]: https://github.com/vbabiy/djangorestframework-camel-case \ No newline at end of file
diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md
index 654cf404..846ac9f9 100644
--- a/docs/api-guide/routers.md
+++ b/docs/api-guide/routers.md
@@ -222,9 +222,6 @@ The following third party packages are also available.
The [drf-nested-routers package][drf-nested-routers] provides routers and relationship fields for working with nested resources.
-[cite]: http://guides.rubyonrails.org/routing.html
-[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
-
## wq.db
The [wq.db package][wq.db] provides an advanced [Router][wq.db-router] class (and singleton instance) that extends `DefaultRouter` with a `register_model()` API. Much like Django's `admin.site.register`, the only required argument to `app.router.register_model` is a model class. Reasonable defaults for a url prefix and viewset will be inferred from the model and global configuration.
@@ -236,5 +233,6 @@ The [wq.db package][wq.db] provides an advanced [Router][wq.db-router] class (an
[cite]: http://guides.rubyonrails.org/routing.html
[route-decorators]: viewsets.html#marking-extra-actions-for-routing
+[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
[wq.db]: http://wq.io/wq.db
[wq.db-router]: http://wq.io/docs/app.py
diff --git a/docs/topics/2.4-accouncement.md b/docs/topics/2.4-accouncement.md
new file mode 100644
index 00000000..a5425d54
--- /dev/null
+++ b/docs/topics/2.4-accouncement.md
@@ -0,0 +1,4 @@
+* Writable nested serializers.
+* List/detail routes.
+* 1.3 Support dropped, install six for <=1.4.?.
+* Note title ordering changed \ No newline at end of file
diff --git a/docs/topics/contributing.md b/docs/topics/contributing.md
index 906950bb..30d292f8 100644
--- a/docs/topics/contributing.md
+++ b/docs/topics/contributing.md
@@ -10,7 +10,7 @@ There are many ways you can contribute to Django REST framework. We'd like it t
The most important thing you can do to help push the REST framework project forward is to be actively involved wherever possible. Code contributions are often overvalued as being the primary way to get involved in a project, we don't believe that needs to be the case.
-If you use REST framework, we'd love you to be vocal about your experiences with it - you might consider writing a blog post about using REST framework, or publishing a tutorial about building a project with a particularJjavascript framework. Experiences from beginners can be particularly helpful because you'll be in the best position to assess which bits of REST framework are more difficult to understand and work with.
+If you use REST framework, we'd love you to be vocal about your experiences with it - you might consider writing a blog post about using REST framework, or publishing a tutorial about building a project with a particular Javascript framework. Experiences from beginners can be particularly helpful because you'll be in the best position to assess which bits of REST framework are more difficult to understand and work with.
Other really great ways you can help move the community forward include helping answer questions on the [discussion group][google-group], or setting up an [email alert on StackOverflow][so-filter] so that you get notified of any new questions with the `django-rest-framework` tag.
diff --git a/docs/topics/credits.md b/docs/topics/credits.md
index 1a838421..d4c00bc4 100644
--- a/docs/topics/credits.md
+++ b/docs/topics/credits.md
@@ -181,6 +181,7 @@ The following people have helped make REST framework great.
* Alex Good - [alexjg]
* Ian Foote - [ian-foote]
* Chuck Harmston - [chuckharmston]
+* Philip Forget - [philipforget]
Many thanks to everyone who's contributed to the project.
@@ -398,3 +399,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter.
[alexjg]: https://github.com/alexjg
[ian-foote]: https://github.com/ian-foote
[chuckharmston]: https://github.com/chuckharmston
+[philipforget]: https://github.com/philipforget
diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md
index 0815bcfb..da17aa74 100644
--- a/docs/topics/release-notes.md
+++ b/docs/topics/release-notes.md
@@ -53,7 +53,9 @@ You can determine your currently installed version using `pip freeze`:
### Master
* JSON renderer now deals with objects that implement a dict-like interface.
+* Fix compatiblity with newer versions of `django-oauth-plus`.
* Bugfix: Refine behavior that calls model manager `all()` across nested serializer relationships, preventing erronous behavior with some non-ORM objects, and preventing unneccessary queryset re-evaluations.
+* Bugfix: Allow defaults on BooleanFields to be properly honored when values are not supplied.
### 2.3.10
@@ -98,6 +100,19 @@ You can determine your currently installed version using `pip freeze`:
* Bugfix: `client.force_authenticate(None)` should also clear session info if it exists.
* Bugfix: Client sending empty string instead of file now clears `FileField`.
* Bugfix: Empty values on ChoiceFields with `required=False` now consistently return `None`.
+* Bugfix: Clients setting `page=0` now simply returns the default page size, instead of disabling pagination. [*]
+
+---
+
+[*] Note that the change in `page=0` behaviour fixes what is considered to be a bug in how clients can effect the pagination size. However if you were relying on this behavior you will need to add the following mixin to your list views in order to preserve the existing behavior.
+
+ class DisablePaginationMixin(object):
+ def get_paginate_by(self, queryset=None):
+ if self.request.QUERY_PARAMS['self.paginate_by_param'] == '0':
+ return None
+ return super(DisablePaginationMixin, self).get_paginate_by(queryset)
+
+---
### 2.3.7
diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md
index e1c0009c..2298df59 100644
--- a/docs/tutorial/1-serialization.md
+++ b/docs/tutorial/1-serialization.md
@@ -183,9 +183,11 @@ At this point we've translated the model instance into Python native datatypes.
Deserialization is similar. First we parse a stream into Python native datatypes...
- import StringIO
+ # This import will use either `StringIO.StringIO` or `io.BytesIO`
+ # as appropriate, depending on if we're running Python 2 or Python 3.
+ from rest_framework.compat import BytesIO
- stream = StringIO.StringIO(content)
+ stream = BytesIO(content)
data = JSONParser().parse(stream)
...then we restore those native datatypes into to a fully populated object instance.
@@ -261,8 +263,7 @@ The root of our API is going to be a view that supports listing all the existing
if serializer.is_valid():
serializer.save()
return JSONResponse(serializer.data, status=201)
- else:
- return JSONResponse(serializer.errors, status=400)
+ return JSONResponse(serializer.errors, status=400)
Note that because we want to be able to POST to this view from clients that won't have a CSRF token we need to mark the view as `csrf_exempt`. This isn't something that you'd normally want to do, and REST framework views actually use more sensible behavior than this, but it'll do for our purposes right now.
@@ -288,8 +289,7 @@ We'll also need a view which corresponds to an individual snippet, and can be us
if serializer.is_valid():
serializer.save()
return JSONResponse(serializer.data)
- else:
- return JSONResponse(serializer.errors, status=400)
+ return JSONResponse(serializer.errors, status=400)
elif request.method == 'DELETE':
snippet.delete()
diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md
index 7fa4f3e4..603edd08 100644
--- a/docs/tutorial/2-requests-and-responses.md
+++ b/docs/tutorial/2-requests-and-responses.md
@@ -59,8 +59,7 @@ We don't need our `JSONResponse` class in `views.py` anymore, so go ahead and de
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
- else:
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
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.
@@ -85,8 +84,7 @@ Here is the view for an individual snippet, in the `views.py` module.
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
- else:
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
elif request.method == 'DELETE':
snippet.delete()
diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md
index b472322a..bdc6b579 100644
--- a/docs/tutorial/4-authentication-and-permissions.md
+++ b/docs/tutorial/4-authentication-and-permissions.md
@@ -167,10 +167,10 @@ In the snippets app, create a new file, `permissions.py`
def has_object_permission(self, request, view, obj):
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
- if request.method in permissions.SAFE_METHODS:
+ if request.method in permissions.SAFE_METHODS:
return True
-
- # Write permissions are only allowed to the owner of the snippet
+
+ # Write permissions are only allowed to the owner of the snippet.
return obj.owner == request.user
Now we can add that custom permission to our snippet instance endpoint, by editing the `permission_classes` property on the `SnippetDetail` class: