diff --git a/api-guide/renderers.html b/api-guide/renderers.html index cb723e6a9..1441b7ba5 100644 --- a/api-guide/renderers.html +++ b/api-guide/renderers.html @@ -311,7 +311,10 @@ def user_count_view(request, format=None):

JSONPRenderer

Renders the request data into JSONP. The JSONP media type provides a mechanism of allowing cross-domain AJAX requests, by wrapping a JSON response in a javascript callback.

The javascript callback function must be set by the client including a callback URL query parameter. For example http://example.com/api/users?callback=jsonpCallback. If the callback function is not explicitly set by the client it will default to 'callback'.

-

Note: If you require cross-domain AJAX requests, you may want to consider using the more modern approach of CORS as an alternative to JSONP. See the CORS documentation for more details.

+
+

Warning: If you require cross-domain AJAX requests, you should almost certainly be using the more modern approach of CORS as an alternative to JSONP. See the CORS documentation for more details.

+

The jsonp approach is essentially a browser hack, and is only appropriate for globally readable API endpoints, where GET requests are unauthenticated and do not require any user permissions.

+

.media_type: application/javascript

.format: '.jsonp'

.charset: utf-8

diff --git a/api-guide/views.html b/api-guide/views.html index c8338560e..8dd319fdd 100644 --- a/api-guide/views.html +++ b/api-guide/views.html @@ -298,9 +298,9 @@ This method is used to enforce permissions and throttling, and perform content n def hello_world(request): return Response({"message": "Hello, world!"}) -

This view will use the default renderers, parsers, authentication classes etc specified in the settings.

+

This view will use the default renderers, parsers, authentication classes etc specified in the settings.

API policy decorators

-

To override the default settings, REST framework provides a set of additional decorators which can be added to your views. These must come after (below) the @api_view decorator. For example, to create a view that uses a throttle to ensure it can only be called once per day by a particular user, use the @throttle_classes decorator, passing a list of throttle classes:

+

To override the default settings, REST framework provides a set of additional decorators which can be added to your views. These must come after (below) the @api_view decorator. For example, to create a view that uses a throttle to ensure it can only be called once per day by a particular user, use the @throttle_classes decorator, passing a list of throttle classes:

from rest_framework.decorators import api_view, throttle_classes
 from rest_framework.throttling import UserRateThrottle