From b676cce61f364095caa0bdbc46c22cdc87b98646 Mon Sep 17 00:00:00 2001 From: Eric Buehl Date: Thu, 18 Jul 2013 19:03:38 -0700 Subject: pedantic doc updates --- docs/api-guide/viewsets.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md index 47e59e2b..0c68afb0 100644 --- a/docs/api-guide/viewsets.md +++ b/docs/api-guide/viewsets.md @@ -98,6 +98,7 @@ For example: from django.contrib.auth.models import User from rest_framework import viewsets + from rest_framework import status from rest_framework.decorators import action from rest_framework.response import Response from myapp.serializers import UserSerializer, PasswordSerializer -- cgit v1.2.3 From 8f2e71a67fad17a0e44df6747ca450a101979c24 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 19 Jul 2013 19:49:20 -0400 Subject: Modified documentation for CSRF as mentioned in #984 --- docs/topics/ajax-csrf-cors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/ajax-csrf-cors.md b/docs/topics/ajax-csrf-cors.md index 4566f38b..0555b84d 100644 --- a/docs/topics/ajax-csrf-cors.md +++ b/docs/topics/ajax-csrf-cors.md @@ -23,7 +23,7 @@ To guard against these type of attacks, you need to do two things: If you're using `SessionAuthentication` you'll need to include valid CSRF tokens for any `POST`, `PUT`, `PATCH` or `DELETE` operations. -The Django documentation describes how to [include CSRF tokens in AJAX requests][csrf-ajax]. +In order to make AJAX requests, you need to include CSRF token in the HTTP header, as [described in the Django documentation][csrf-ajax]. ## CORS -- cgit v1.2.3 From 2e18fbe373b3216b451ac163ec822e04b1e76120 Mon Sep 17 00:00:00 2001 From: Pavel Zinovkin Date: Sun, 21 Jul 2013 17:03:58 +0400 Subject: Updated EmailField error message. This one already available in django translations. https://github.com/django/django/blob/master/django/conf/locale/ru/LC_MESSAGES/django.po#L343--- rest_framework/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 6e5ee470..f9931887 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -512,7 +512,7 @@ class EmailField(CharField): form_field_class = forms.EmailField default_error_messages = { - 'invalid': _('Enter a valid e-mail address.'), + 'invalid': _('Enter a valid email address.'), } default_validators = [validators.validate_email] -- cgit v1.2.3 From b6d6feaa0210bef225f2dad0d5765b32ecfc8cd0 Mon Sep 17 00:00:00 2001 From: Pavel Zinovkin Date: Sun, 21 Jul 2013 22:43:19 +0400 Subject: Fixed test --- rest_framework/tests/test_serializer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/tests/test_serializer.py b/rest_framework/tests/test_serializer.py index 38acc354..c2497660 100644 --- a/rest_framework/tests/test_serializer.py +++ b/rest_framework/tests/test_serializer.py @@ -494,7 +494,7 @@ class CustomValidationTests(TestCase): } serializer = self.CommentSerializerWithFieldValidator(data=wrong_data) self.assertFalse(serializer.is_valid()) - self.assertEqual(serializer.errors, {'email': ['Enter a valid e-mail address.']}) + self.assertEqual(serializer.errors, {'email': ['Enter a valid email address.']}) class PositiveIntegerAsChoiceTests(TestCase): -- cgit v1.2.3 From 61a242e27b483bb9570cc8eec2bc42a81ed09c45 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 23 Jul 2013 10:40:54 -0400 Subject: added script block to list of blocks Phew, was afraid I wouldn't be able to overwrite this section..--- docs/topics/browsable-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/topics/browsable-api.md b/docs/topics/browsable-api.md index 895b3c5f..2ae8cadb 100644 --- a/docs/topics/browsable-api.md +++ b/docs/topics/browsable-api.md @@ -75,6 +75,7 @@ All of the blocks available in the browsable API base template that can be used * `branding` - Branding section of the navbar, see [Bootstrap components][bcomponentsnav]. * `breadcrumbs` - Links showing resource nesting, allowing the user to go back up the resources. It's recommended to preserve these, but they can be overridden using the breadcrumbs block. * `footer` - Any copyright notices or similar footer materials can go here (by default right-aligned). +* `script` - JavaScript files for the page. * `style` - CSS stylesheets for the page. * `title` - Title of the page. * `userlinks` - This is a list of links on the right of the header, by default containing login/logout links. To add links instead of replace, use `{{ block.super }}` to preserve the authentication links. @@ -170,4 +171,4 @@ You can now add the `autocomplete_light.ChoiceWidget` widget to the serializer f [autocomplete-packages]: https://www.djangopackages.com/grids/g/auto-complete/ [django-autocomplete-light]: https://github.com/yourlabs/django-autocomplete-light [django-autocomplete-light-install]: http://django-autocomplete-light.readthedocs.org/en/latest/#install -[autocomplete-image]: ../img/autocomplete.png \ No newline at end of file +[autocomplete-image]: ../img/autocomplete.png -- cgit v1.2.3 From c23412b51c5d8abbe1c103d7e177606644f9f0b7 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Wed, 24 Jul 2013 11:02:10 +0200 Subject: Add @pzinovkin for #995 thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/credits.md b/docs/topics/credits.md index 38146327..f6b59ed4 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -147,6 +147,7 @@ The following people have helped make REST framework great. * Rudolf Olah - [omouse] * Gertjan Oude Lohuis - [gertjanol] * Matthias Jacob - [cyroxx] +* Pavel Zinovkin - [pzinovkin] Many thanks to everyone who's contributed to the project. @@ -330,3 +331,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [omouse]: https://github.com/omouse [gertjanol]: https://github.com/gertjanol [cyroxx]: https://github.com/cyroxx +[pzinovkin]: https://github.com/pzinovkin -- cgit v1.2.3 From 3fbb4097e64592cd02924302fcb4e63dc1b6062d Mon Sep 17 00:00:00 2001 From: Will Kahn-Greene Date: Thu, 25 Jul 2013 12:55:03 -0400 Subject: Fix *Throttle class names in the docs * AnonThrottle -> AnonRateThrottle * UserThrottle -> UserRateThrottle * ScopedThrottle -> ScopedRateThrottle * (cosmetic) removed one errant whitespace character Fixes #1006. --- docs/api-guide/throttling.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md index d6de85ba..56f32f58 100644 --- a/docs/api-guide/throttling.md +++ b/docs/api-guide/throttling.md @@ -12,7 +12,7 @@ As with permissions, multiple throttles may be used. Your API might have a rest Another scenario where you might want to use multiple throttles would be if you need to impose different constraints on different parts of the API, due to some services being particularly resource-intensive. -Multiple throttles can also be used if you want to impose both burst throttling rates, and sustained throttling rates. For example, you might want to limit a user to a maximum of 60 requests per minute, and 1000 requests per day. +Multiple throttles can also be used if you want to impose both burst throttling rates, and sustained throttling rates. For example, you might want to limit a user to a maximum of 60 requests per minute, and 1000 requests per day. Throttles do not necessarily only refer to rate-limiting requests. For example a storage service might also need to throttle against bandwidth, and a paid data service might want to throttle against a certain number of a records being accessed. @@ -44,7 +44,7 @@ You can also set the throttling policy on a per-view or per-viewset basis, using the `APIView` class based views. class ExampleView(APIView): - throttle_classes = (UserThrottle,) + throttle_classes = (UserRateThrottle,) def get(self, request, format=None): content = { @@ -55,7 +55,7 @@ using the `APIView` class based views. Or, if you're using the `@api_view` decorator with function based views. @api_view('GET') - @throttle_classes(UserThrottle) + @throttle_classes(UserRateThrottle) def example_view(request, format=None): content = { 'status': 'request was permitted' @@ -72,22 +72,22 @@ The throttle classes provided by REST framework use Django's cache backend. You ## AnonRateThrottle -The `AnonThrottle` will only ever throttle unauthenticated users. The IP address of the incoming request is used to generate a unique key to throttle against. +The `AnonRateThrottle` will only ever throttle unauthenticated users. The IP address of the incoming request is used to generate a unique key to throttle against. The allowed request rate is determined from one of the following (in order of preference). -* The `rate` property on the class, which may be provided by overriding `AnonThrottle` and setting the property. +* The `rate` property on the class, which may be provided by overriding `AnonRateThrottle` and setting the property. * The `DEFAULT_THROTTLE_RATES['anon']` setting. -`AnonThrottle` is suitable if you want to restrict the rate of requests from unknown sources. +`AnonRateThrottle` is suitable if you want to restrict the rate of requests from unknown sources. ## UserRateThrottle -The `UserThrottle` will throttle users to a given rate of requests across the API. The user id is used to generate a unique key to throttle against. Unauthenticated requests will fall back to using the IP address of the incoming request to generate a unique key to throttle against. +The `UserRateThrottle` will throttle users to a given rate of requests across the API. The user id is used to generate a unique key to throttle against. Unauthenticated requests will fall back to using the IP address of the incoming request to generate a unique key to throttle against. The allowed request rate is determined from one of the following (in order of preference). -* The `rate` property on the class, which may be provided by overriding `UserThrottle` and setting the property. +* The `rate` property on the class, which may be provided by overriding `UserRateThrottle` and setting the property. * The `DEFAULT_THROTTLE_RATES['user']` setting. An API may have multiple `UserRateThrottles` in place at the same time. To do so, override `UserRateThrottle` and set a unique "scope" for each class. @@ -113,11 +113,11 @@ For example, multiple user throttle rates could be implemented by using the foll } } -`UserThrottle` is suitable if you want simple global rate restrictions per-user. +`UserRateThrottle` is suitable if you want simple global rate restrictions per-user. ## ScopedRateThrottle -The `ScopedThrottle` class can be used to restrict access to specific parts of the API. This throttle will only be applied if the view that is being accessed includes a `.throttle_scope` property. The unique throttle key will then be formed by concatenating the "scope" of the request with the unique user id or IP address. +The `ScopedRateThrottle` class can be used to restrict access to specific parts of the API. This throttle will only be applied if the view that is being accessed includes a `.throttle_scope` property. The unique throttle key will then be formed by concatenating the "scope" of the request with the unique user id or IP address. The allowed request rate is determined by the `DEFAULT_THROTTLE_RATES` setting using a key from the request "scope". -- cgit v1.2.3 From 0fa9866848238ed355461a619e5aa9a148403f5f Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Fri, 26 Jul 2013 09:26:32 +0200 Subject: Add @willkg for #1007 thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/credits.md b/docs/topics/credits.md index f6b59ed4..dcd147e3 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -148,6 +148,7 @@ The following people have helped make REST framework great. * Gertjan Oude Lohuis - [gertjanol] * Matthias Jacob - [cyroxx] * Pavel Zinovkin - [pzinovkin] +* Will Kahn-Greene - [willkg] Many thanks to everyone who's contributed to the project. @@ -332,3 +333,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [gertjanol]: https://github.com/gertjanol [cyroxx]: https://github.com/cyroxx [pzinovkin]: https://github.com/pzinovkin +[willkg]: https://github.com/willkg -- cgit v1.2.3 From 103fed966751680d4ac3dc8125b6807e34bb436a Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 26 Jul 2013 10:59:51 -0400 Subject: Fixed reversed arguments in assertion --- rest_framework/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 023f7ccf..682a99a4 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -690,7 +690,7 @@ class ModelSerializer(Serializer): assert field_name in ret, \ "Noexistant field '%s' specified in `read_only_fields` " \ "on serializer '%s'." % \ - (self.__class__.__name__, field_name) + (field_name, self.__class__.__name__) ret[field_name].read_only = True return ret -- cgit v1.2.3 From 9088c18da85bc56b363f5f1995159cc26e102254 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 26 Jul 2013 11:03:37 -0400 Subject: Added to the credits --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/credits.md b/docs/topics/credits.md index dcd147e3..f6e77996 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -149,6 +149,7 @@ The following people have helped make REST framework great. * Matthias Jacob - [cyroxx] * Pavel Zinovkin - [pzinovkin] * Will Kahn-Greene - [willkg] +* Kevin Brown - [kevin-brown] Many thanks to everyone who's contributed to the project. @@ -334,3 +335,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [cyroxx]: https://github.com/cyroxx [pzinovkin]: https://github.com/pzinovkin [willkg]: https://github.com/willkg +[kevin-brown]: https://github.com/kevin-brown -- cgit v1.2.3 From 3a898a11f7683f0f5448ce4d28af212c04befea7 Mon Sep 17 00:00:00 2001 From: Rodrigo Martell Date: Sat, 27 Jul 2013 10:09:56 +1000 Subject: Fix Tutorial5 serializers.py typo [Issue #N/A] A slight typo at Tutorial5 causing an Exception "name 'models' is not defined". A subtle one that can confuse Python/Django noobs like me. --- docs/tutorial/5-relationships-and-hyperlinked-apis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md index 2e013a94..2cf44bf9 100644 --- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md +++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md @@ -80,7 +80,7 @@ We can easily re-write our existing serializers to use hyperlinking. highlight = serializers.HyperlinkedIdentityField(view_name='snippet-highlight', format='html') class Meta: - model = models.Snippet + model = Snippet fields = ('url', 'highlight', 'owner', 'title', 'code', 'linenos', 'language', 'style') -- cgit v1.2.3 From e98c229e5aa86f0da872583c08f353d974d9cc98 Mon Sep 17 00:00:00 2001 From: Stephan Groß Date: Sun, 28 Jul 2013 18:51:22 +0200 Subject: Add @coderigo for #1011 thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/credits.md b/docs/topics/credits.md index f6e77996..95cac717 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -150,6 +150,7 @@ The following people have helped make REST framework great. * Pavel Zinovkin - [pzinovkin] * Will Kahn-Greene - [willkg] * Kevin Brown - [kevin-brown] +* Rodrigo Martell - [coderigo] Many thanks to everyone who's contributed to the project. @@ -334,5 +335,6 @@ You can also contact [@_tomchristie][twitter] directly on twitter. [gertjanol]: https://github.com/gertjanol [cyroxx]: https://github.com/cyroxx [pzinovkin]: https://github.com/pzinovkin +[coderigo]: https://github.com/coderigo [willkg]: https://github.com/willkg [kevin-brown]: https://github.com/kevin-brown -- cgit v1.2.3