From d198b1abe6b96bbdd84e4c2622d996f770c69edd Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Mon, 29 May 2017 17:07:50 +0100 Subject: [PATCH 001/217] Add Django manage command to create a DRF user Token --- .../authtoken/management/__init__.py | 0 .../authtoken/management/commands/__init__.py | 0 .../management/commands/drf_create_token.py | 20 +++++++++++++++++++ tests/test_authtoken.py | 15 ++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 rest_framework/authtoken/management/__init__.py create mode 100644 rest_framework/authtoken/management/commands/__init__.py create mode 100644 rest_framework/authtoken/management/commands/drf_create_token.py diff --git a/rest_framework/authtoken/management/__init__.py b/rest_framework/authtoken/management/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/rest_framework/authtoken/management/commands/__init__.py b/rest_framework/authtoken/management/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/rest_framework/authtoken/management/commands/drf_create_token.py b/rest_framework/authtoken/management/commands/drf_create_token.py new file mode 100644 index 000000000..ccd400ed5 --- /dev/null +++ b/rest_framework/authtoken/management/commands/drf_create_token.py @@ -0,0 +1,20 @@ +from django.contrib.auth.models import User +from django.core.management.base import BaseCommand +from rest_framework.authtoken.models import Token + + +class Command(BaseCommand): + help = 'Create DRF Token for a given user' + + def create_user_token(self, username): + user = User.objects.get(username=username) + token = Token.objects.get_or_create(user=user) + return token[0] + + def add_arguments(self, parser): + parser.add_argument('username', type=str, nargs='+') + + def handle(self, *args, **options): + username = options['username'] + token = self.create_user_token(username) + print('Generated token {0} for user {1}'.format(token.key, username)) diff --git a/tests/test_authtoken.py b/tests/test_authtoken.py index 54ac1848d..3b5a618e3 100644 --- a/tests/test_authtoken.py +++ b/tests/test_authtoken.py @@ -4,6 +4,8 @@ from django.contrib.auth.models import User from django.test import TestCase from rest_framework.authtoken.admin import TokenAdmin +from rest_framework.authtoken.management.commands.drf_create_token import \ + Command as AuthTokenCommand from rest_framework.authtoken.models import Token from rest_framework.authtoken.serializers import AuthTokenSerializer from rest_framework.exceptions import ValidationError @@ -33,3 +35,16 @@ class AuthTokenTests(TestCase): self.user.set_password(data['password']) self.user.save() assert AuthTokenSerializer(data=data).is_valid() + + +class AuthTokenCommandTests(TestCase): + + def setUp(self): + self.site = site + self.user = User.objects.create_user(username='test_user') + + def test_command_create_user_token(self): + token = AuthTokenCommand().create_user_token(self.user.username) + assert token is not None + token_saved = Token.objects.first() + assert token.key == token_saved.key From 84e22cc2f3866078a06a464636e4ec6c1a7fec47 Mon Sep 17 00:00:00 2001 From: Bekhzod Tillakhanov Date: Tue, 30 May 2017 00:15:07 +0500 Subject: [PATCH 002/217] Scheme fix when unauth and Flask8 lint fix --- rest_framework/templates/rest_framework/docs/document.html | 3 ++- rest_framework/templates/rest_framework/docs/sidebar.html | 2 ++ tests/test_atomic_requests.py | 1 + tests/test_fields.py | 1 - tests/test_permissions.py | 3 +++ tests/test_renderers.py | 1 + tests/test_request.py | 1 + tests/test_response.py | 1 + tests/test_reverse.py | 1 + tests/test_schemas.py | 1 + tests/test_validation.py | 1 + 11 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rest_framework/templates/rest_framework/docs/document.html b/rest_framework/templates/rest_framework/docs/document.html index ef5f5966b..274eee4e3 100644 --- a/rest_framework/templates/rest_framework/docs/document.html +++ b/rest_framework/templates/rest_framework/docs/document.html @@ -13,7 +13,7 @@ {% if 'javascript' in langs %}{% include "rest_framework/docs/langs/javascript-intro.html" %}{% endif %} - +{% if document.data %} {% for section_key, section in document.data|items %} {% if section_key %}

{{ section_key }} @@ -28,3 +28,4 @@ {% for link_key, link in document.links|items %} {% include "rest_framework/docs/link.html" %} {% endfor %} +{% endif %} diff --git a/rest_framework/templates/rest_framework/docs/sidebar.html b/rest_framework/templates/rest_framework/docs/sidebar.html index c6ac26f66..f5f84a2e5 100644 --- a/rest_framework/templates/rest_framework/docs/sidebar.html +++ b/rest_framework/templates/rest_framework/docs/sidebar.html @@ -5,6 +5,7 @@

{% endif %} - {% for link_key, link in section.links|items %} + {% for link_key, link in section|schema_links|items %} {% include "rest_framework/docs/link.html" %} {% endfor %} {% endfor %} diff --git a/rest_framework/templates/rest_framework/docs/sidebar.html b/rest_framework/templates/rest_framework/docs/sidebar.html index 7e20e2485..c4eaa120b 100644 --- a/rest_framework/templates/rest_framework/docs/sidebar.html +++ b/rest_framework/templates/rest_framework/docs/sidebar.html @@ -10,7 +10,7 @@ From a1546cc26633b748dd5c79c9dc222ff84b79d43e Mon Sep 17 00:00:00 2001 From: Woile Date: Thu, 17 Aug 2017 21:14:26 +0200 Subject: [PATCH 038/217] [NEW] Tests for templatetags.schema_links --- rest_framework/templatetags/rest_framework.py | 2 +- tests/test_templatetags.py | 315 +++++++++++++++++- 2 files changed, 315 insertions(+), 2 deletions(-) diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index 5fd189548..a2ee5ccdd 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -249,7 +249,7 @@ def schema_links(section, sec_key=None): """ Recursively find every link in a schema, even nested. """ - NESTED_FORMAT = '%s > %s' + NESTED_FORMAT = '%s > %s' # this format is used in docs/js/api.js:normalizeKeys links = section.links if section.data: data = section.data.items() diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py index 87d5cbc81..dfbd5d9de 100644 --- a/tests/test_templatetags.py +++ b/tests/test_templatetags.py @@ -1,13 +1,16 @@ # encoding: utf-8 from __future__ import unicode_literals +import unittest + from django.test import TestCase +from rest_framework.compat import coreapi, coreschema from rest_framework.relations import Hyperlink from rest_framework.templatetags import rest_framework from rest_framework.templatetags.rest_framework import ( add_nested_class, add_query_param, as_string, break_long_headers, - format_value, get_pagination_html, urlize_quoted_links + format_value, get_pagination_html, schema_links, urlize_quoted_links ) from rest_framework.test import APIRequestFactory @@ -300,3 +303,313 @@ class URLizerTests(TestCase): data['"foo_set": [\n "http://api/foos/1/"\n], '] = \ '"foo_set": [\n "http://api/foos/1/"\n], ' self._urlize_dict_check(data) + + +@unittest.skipUnless(coreapi, 'coreapi is not installed') +class SchemaLinksTests(TestCase): + + def test_schema_with_empty_links(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'users': { + 'list': {} + } + } + ) + section = schema['users'] + flat_links = schema_links(section) + assert len(flat_links) is 0 + + def test_single_action(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'users': { + 'list': coreapi.Link( + url='/users/', + action='get', + fields=[] + ) + } + } + ) + section = schema['users'] + flat_links = schema_links(section) + assert len(flat_links) is 1 + assert 'list' in flat_links + + def test_default_actions(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'users': { + 'create': coreapi.Link( + url='/users/', + action='post', + fields=[] + ), + 'list': coreapi.Link( + url='/users/', + action='get', + fields=[] + ), + 'read': coreapi.Link( + url='/users/{id}/', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'update': coreapi.Link( + url='/users/{id}/', + action='patch', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + } + } + ) + section = schema['users'] + flat_links = schema_links(section) + assert len(flat_links) is 4 + assert 'list' in flat_links + assert 'create' in flat_links + assert 'read' in flat_links + assert 'update' in flat_links + + def test_default_actions_and_single_custom_action(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'users': { + 'create': coreapi.Link( + url='/users/', + action='post', + fields=[] + ), + 'list': coreapi.Link( + url='/users/', + action='get', + fields=[] + ), + 'read': coreapi.Link( + url='/users/{id}/', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'update': coreapi.Link( + url='/users/{id}/', + action='patch', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'friends': coreapi.Link( + url='/users/{id}/friends', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + } + } + ) + section = schema['users'] + flat_links = schema_links(section) + assert len(flat_links) is 5 + assert 'list' in flat_links + assert 'create' in flat_links + assert 'read' in flat_links + assert 'update' in flat_links + assert 'friends' in flat_links + + def test_default_actions_and_single_custom_action_two_methods(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'users': { + 'create': coreapi.Link( + url='/users/', + action='post', + fields=[] + ), + 'list': coreapi.Link( + url='/users/', + action='get', + fields=[] + ), + 'read': coreapi.Link( + url='/users/{id}/', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'update': coreapi.Link( + url='/users/{id}/', + action='patch', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'friends': { + 'list': coreapi.Link( + url='/users/{id}/friends', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'create': coreapi.Link( + url='/users/{id}/friends', + action='post', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + } + } + } + ) + section = schema['users'] + flat_links = schema_links(section) + assert len(flat_links) is 6 + assert 'list' in flat_links + assert 'create' in flat_links + assert 'read' in flat_links + assert 'update' in flat_links + assert 'friends > list' in flat_links + assert 'friends > create' in flat_links + + def test_multiple_nested_routes(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'animals': { + 'dog': { + 'vet': { + 'list': coreapi.Link( + url='/animals/dog/{id}/vet', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + }, + 'read': coreapi.Link( + url='/animals/dog/{id}', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + }, + 'cat': { + 'list': coreapi.Link( + url='/animals/cat/', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'create': coreapi.Link( + url='/aniamls/cat', + action='post', + fields=[] + ) + } + } + } + ) + section = schema['animals'] + flat_links = schema_links(section) + assert len(flat_links) is 4 + assert 'cat > create' in flat_links + assert 'cat > list' in flat_links + assert 'dog > read' in flat_links + assert 'dog > vet > list' in flat_links + + def test_multiple_resources_with_multiple_nested_routes(self): + schema = coreapi.Document( + url='', + title='Example API', + content={ + 'animals': { + 'dog': { + 'vet': { + 'list': coreapi.Link( + url='/animals/dog/{id}/vet', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + }, + 'read': coreapi.Link( + url='/animals/dog/{id}', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + }, + 'cat': { + 'list': coreapi.Link( + url='/animals/cat/', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ), + 'create': coreapi.Link( + url='/aniamls/cat', + action='post', + fields=[] + ) + } + }, + 'farmers': { + 'silo': { + 'soy': { + 'list': coreapi.Link( + url='/farmers/silo/{id}/soy', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + }, + 'list': coreapi.Link( + url='/farmers/silo', + action='get', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + ] + ) + } + } + } + ) + section = schema['animals'] + flat_links = schema_links(section) + assert len(flat_links) is 4 + assert 'cat > create' in flat_links + assert 'cat > list' in flat_links + assert 'dog > read' in flat_links + assert 'dog > vet > list' in flat_links + + section = schema['farmers'] + flat_links = schema_links(section) + assert len(flat_links) is 2 + assert 'silo > list' in flat_links + assert 'silo > soy > list' in flat_links From c868378c71d7bd9883c1448977e185b1cd7c756c Mon Sep 17 00:00:00 2001 From: kycool Date: Fri, 18 Aug 2017 12:12:01 +0800 Subject: [PATCH 039/217] Update fields.py modify to_choices_dict document --- 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 9cc9ab03f..242d0f978 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -142,7 +142,7 @@ def to_choices_dict(choices): to_choices_dict([1]) -> {1: 1} to_choices_dict([(1, '1st'), (2, '2nd')]) -> {1: '1st', 2: '2nd'} - to_choices_dict([('Group', ((1, '1st'), 2))]) -> {'Group': {1: '1st', 2: '2nd'}} + to_choices_dict([('Group', ((1, '1st'), 2))]) -> {'Group': {1: '1st', 2: '2'}} """ # Allow single, paired or grouped choices style: # choices = [1, 2, 3] From 56021f9e7769138e0ae69115f01ed45b5bc8be3f Mon Sep 17 00:00:00 2001 From: Lim H Date: Sun, 20 Aug 2017 17:12:56 +0100 Subject: [PATCH 040/217] Add tests for list field to schema --- tests/test_schemas.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 2b8673480..b435dfdd7 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -39,6 +39,11 @@ class ExampleSerializer(serializers.Serializer): hidden = serializers.HiddenField(default='hello') +class AnotherSerializerWithListFields(serializers.Serializer): + a = serializers.ListField(child=serializers.IntegerField()) + b = serializers.ListSerializer(child=serializers.CharField()) + + class AnotherSerializer(serializers.Serializer): c = serializers.CharField(required=True) d = serializers.CharField(required=False) @@ -57,6 +62,13 @@ class ExampleViewSet(ModelViewSet): """ return super(ExampleSerializer, self).retrieve(self, request) + @detail_route(methods=['post'], serializer_class=AnotherSerializerWithListFields) + def custom_action_with_list_fields(self, request, pk): + """ + A custom action using both list field and list serializer in the serializer. + """ + return super(ExampleSerializer, self).retrieve(self, request) + @list_route() def custom_list_action(self, request): return super(ExampleViewSet, self).list(self, request) @@ -174,6 +186,17 @@ class TestRouterGeneratedSchema(TestCase): coreapi.Field('d', required=False, location='form', schema=coreschema.String(title='D')), ] ), + 'custom_action_with_list_fields': coreapi.Link( + url='/example/{id}/custom_action_with_list_fields/', + action='post', + encoding='application/json', + description='A custom action using both list field and list serializer in the serializer.', + fields=[ + coreapi.Field('id', required=True, location='path', schema=coreschema.String()), + coreapi.Field('a', required=True, location='form', schema=coreschema.Array(title='A', items=coreschema.Integer())), + coreapi.Field('b', required=True, location='form', schema=coreschema.Array(title='B', items=coreschema.String())), + ] + ), 'custom_list_action': coreapi.Link( url='/example/custom_list_action/', action='get' From 81527a2863cbac78acf392f081df2e7868ea285b Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 21 Aug 2017 11:50:00 +0200 Subject: [PATCH 041/217] Release notes for 3.6.4 --- docs/topics/release-notes.md | 59 +++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 7bdd7b0b1..f4a83324c 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -40,6 +40,34 @@ You can determine your currently installed version using `pip freeze`: ## 3.6.x series +### 3.6.4 + +**Date**: [21st August 2017][3.6.4-milestone] + +* Ignore any invalidly formed query parameters for OrderingFilter. [#5131][gh5131] +* Improve memory footprint when reading large JSON requests. [#5147][gh5147] +* Fix schema generation for pagination. [#5161][gh5161] +* Fix exception when `HTML_CUTOFF` is set to `None`. [#5174][gh5174] +* Fix browsable API not supporting `multipart/form-data` correctly. [#5176][gh5176] +* Fixed `test_hyperlinked_related_lookup_url_encoded_exists`. [#5179][gh5179] +* Make sure max_length is in FileField kwargs. [#5186][gh5186] +* Fix `list_route` & `detail_route` with kwargs contains curly bracket in `url_path` [#5187][gh5187] +* Add Django manage command to create a DRF user Token. [#5188][gh5188] +* Ensure API documentation templates do not check for user authentication [#5162][gh5162] +* Fix special case where OneToOneField is also primary key. [#5192][gh5192] +* Added aria-label and a new region for accessibility purposes in base.html [#5196][gh5196] +* Quote nested API parameters in api.js. [#5214][gh5214] +* Set ViewSet args/kwargs/request before dispatch. [#5229][gh5229] +* Added unicode support to SlugField. [#5231][gh5231] +* Fix HiddenField appears in Raw Data form initial content. [#5259][gh5259] +* Raise validation error on invalid timezone parsing. [#5261][gh5261] +* Fix SearchFilter to-many behavior/performance. [#5264][gh5264] +* Simplified chained comparisons and minor code fixes. [#5276][gh5276] +* RemoteUserAuthentication, docs, and tests. [#5306][gh5306] +* Revert "Cached the field's root and context property" [#5313][gh5313] +* Fix introspection of list field in schema. [#5326][gh5326] +* Fix interactive docs for multiple nested and extra methods. [#5334][gh5334] + ### 3.6.3 **Date**: [12th May 2017][3.6.3-milestone] @@ -716,6 +744,7 @@ For older release notes, [please see the version 2.x documentation][old-release- [3.6.1-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.1+Release%22 [3.6.2-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.2+Release%22 [3.6.3-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.3+Release%22 +[3.6.4-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.4+Release%22 [gh2013]: https://github.com/encode/django-rest-framework/issues/2013 @@ -1326,8 +1355,8 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh4955]: https://github.com/encode/django-rest-framework/issues/4955 [gh4956]: https://github.com/encode/django-rest-framework/issues/4956 [gh4949]: https://github.com/encode/django-rest-framework/issues/4949 - + [gh5126]: https://github.com/encode/django-rest-framework/issues/5126 [gh5085]: https://github.com/encode/django-rest-framework/issues/5085 [gh4437]: https://github.com/encode/django-rest-framework/issues/4437 @@ -1360,3 +1389,31 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh4968]: https://github.com/encode/django-rest-framework/issues/4968 [gh5089]: https://github.com/encode/django-rest-framework/issues/5089 [gh5117]: https://github.com/encode/django-rest-framework/issues/5117 + + +[gh5334]: https://github.com/encode/django-rest-framework/issues/5334 +[gh5326]: https://github.com/encode/django-rest-framework/issues/5326 +[gh5313]: https://github.com/encode/django-rest-framework/issues/5313 +[gh5306]: https://github.com/encode/django-rest-framework/issues/5306 +[gh5276]: https://github.com/encode/django-rest-framework/issues/5276 +[gh5264]: https://github.com/encode/django-rest-framework/issues/5264 +[gh5261]: https://github.com/encode/django-rest-framework/issues/5261 +[gh5259]: https://github.com/encode/django-rest-framework/issues/5259 +[gh5231]: https://github.com/encode/django-rest-framework/issues/5231 +[gh5229]: https://github.com/encode/django-rest-framework/issues/5229 +[gh5214]: https://github.com/encode/django-rest-framework/issues/5214 +[gh5196]: https://github.com/encode/django-rest-framework/issues/5196 +[gh5192]: https://github.com/encode/django-rest-framework/issues/5192 +[gh5162]: https://github.com/encode/django-rest-framework/issues/5162 +[gh5188]: https://github.com/encode/django-rest-framework/issues/5188 +[gh5187]: https://github.com/encode/django-rest-framework/issues/5187 +[gh5186]: https://github.com/encode/django-rest-framework/issues/5186 +[gh5179]: https://github.com/encode/django-rest-framework/issues/5179 +[gh5176]: https://github.com/encode/django-rest-framework/issues/5176 +[gh5174]: https://github.com/encode/django-rest-framework/issues/5174 +[gh5161]: https://github.com/encode/django-rest-framework/issues/5161 +[gh5147]: https://github.com/encode/django-rest-framework/issues/5147 +[gh5131]: https://github.com/encode/django-rest-framework/issues/5131 + + + From 68d818fcc72b15851f1427296f7a4ed57cb4524e Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 21 Aug 2017 12:02:14 +0200 Subject: [PATCH 042/217] Update content from Transifex --- .../locale/ar/LC_MESSAGES/django.po | 23 +- .../locale/ca/LC_MESSAGES/django.po | 2 +- .../locale/cs/LC_MESSAGES/django.po | 2 +- .../locale/da/LC_MESSAGES/django.po | 28 +- .../locale/de/LC_MESSAGES/django.po | 28 +- .../locale/el/LC_MESSAGES/django.po | 2 +- .../locale/es/LC_MESSAGES/django.po | 11 +- .../locale/et/LC_MESSAGES/django.po | 2 +- .../locale/fi/LC_MESSAGES/django.po | 30 +- .../locale/fr/LC_MESSAGES/django.po | 10 +- .../locale/hu/LC_MESSAGES/django.po | 2 +- .../locale/it/LC_MESSAGES/django.po | 2 +- .../locale/ja/LC_MESSAGES/django.po | 13 +- .../locale/ko_KR/LC_MESSAGES/django.po | 35 +- .../locale/lv/LC_MESSAGES/django.po | 440 ++++++++++++++++++ .../locale/mk/LC_MESSAGES/django.po | 58 +-- .../locale/nb/LC_MESSAGES/django.po | 2 +- .../locale/nl/LC_MESSAGES/django.po | 15 +- .../locale/pl/LC_MESSAGES/django.po | 13 +- .../locale/pt_BR/LC_MESSAGES/django.po | 2 +- .../locale/ro/LC_MESSAGES/django.po | 2 +- .../locale/ru/LC_MESSAGES/django.po | 25 +- .../locale/sk/LC_MESSAGES/django.po | 2 +- .../locale/sl/LC_MESSAGES/django.po | 440 ++++++++++++++++++ .../locale/sv/LC_MESSAGES/django.po | 10 +- .../locale/tr/LC_MESSAGES/django.po | 4 +- .../locale/tr_TR/LC_MESSAGES/django.po | 4 +- .../locale/uk/LC_MESSAGES/django.po | 11 +- .../locale/zh_CN/LC_MESSAGES/django.po | 18 +- .../locale/zh_Hans/LC_MESSAGES/django.po | 29 +- 30 files changed, 1078 insertions(+), 187 deletions(-) create mode 100644 rest_framework/locale/lv/LC_MESSAGES/django.po create mode 100644 rest_framework/locale/sl/LC_MESSAGES/django.po diff --git a/rest_framework/locale/ar/LC_MESSAGES/django.po b/rest_framework/locale/ar/LC_MESSAGES/django.po index 314356654..ea53a2905 100644 --- a/rest_framework/locale/ar/LC_MESSAGES/django.po +++ b/rest_framework/locale/ar/LC_MESSAGES/django.po @@ -3,15 +3,16 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: -# Bashar Al-Abdulhadi, 2016 +# aymen chaieb , 2017 +# Bashar Al-Abdulhadi, 2016-2017 # Eyad Toma , 2015 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-15 17:08+0000\n" +"Last-Translator: aymen chaieb \n" "Language-Team: Arabic (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ar/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -54,7 +55,7 @@ msgstr "" #: authentication.py:195 msgid "Invalid token." -msgstr "رمز غير صحيح" +msgstr "رمز غير صحيح." #: authtoken/apps.py:7 msgid "Auth Token" @@ -316,15 +317,15 @@ msgstr "أرسل" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "تصاعدي" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "تنازلي" #: pagination.py:193 msgid "Invalid page." -msgstr "صفحة غير صحيحة" +msgstr "صفحة غير صحيحة." #: pagination.py:427 msgid "Invalid cursor" @@ -382,13 +383,13 @@ msgstr "الترتيب" #: templates/rest_framework/filters/search.html:2 msgid "Search" -msgstr "البحث" +msgstr "بحث" #: templates/rest_framework/horizontal/radio.html:2 #: templates/rest_framework/inline/radio.html:2 #: templates/rest_framework/vertical/radio.html:2 msgid "None" -msgstr "" +msgstr "لا شيء" #: templates/rest_framework/horizontal/select_multiple.html:2 #: templates/rest_framework/inline/select_multiple.html:2 @@ -398,7 +399,7 @@ msgstr "" #: validators.py:43 msgid "This field must be unique." -msgstr "" +msgstr "هذا الحقل يجب أن يكون وحيد" #: validators.py:97 msgid "The fields {field_names} must make a unique set." @@ -438,4 +439,4 @@ msgstr "" #: views.py:88 msgid "Permission denied." -msgstr "" +msgstr "حق غير مصرح به" diff --git a/rest_framework/locale/ca/LC_MESSAGES/django.po b/rest_framework/locale/ca/LC_MESSAGES/django.po index 56f46319f..f82de0068 100644 --- a/rest_framework/locale/ca/LC_MESSAGES/django.po +++ b/rest_framework/locale/ca/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Catalan (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ca/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/cs/LC_MESSAGES/django.po b/rest_framework/locale/cs/LC_MESSAGES/django.po index 8ba979350..b6ee1ea48 100644 --- a/rest_framework/locale/cs/LC_MESSAGES/django.po +++ b/rest_framework/locale/cs/LC_MESSAGES/django.po @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Czech (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/cs/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/da/LC_MESSAGES/django.po b/rest_framework/locale/da/LC_MESSAGES/django.po index 2903376ad..900695649 100644 --- a/rest_framework/locale/da/LC_MESSAGES/django.po +++ b/rest_framework/locale/da/LC_MESSAGES/django.po @@ -3,15 +3,15 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: -# Mads Jensen , 2015-2016 +# Mads Jensen , 2015-2017 # Mikkel Munch Mortensen <3xm@detfalskested.dk>, 2015 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Mads Jensen \n" "Language-Team: Danish (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/da/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -62,31 +62,31 @@ msgstr "" #: authtoken/models.py:15 msgid "Key" -msgstr "" +msgstr "Nøgle" #: authtoken/models.py:18 msgid "User" -msgstr "" +msgstr "Bruger" #: authtoken/models.py:20 msgid "Created" -msgstr "" +msgstr "Oprettet" #: authtoken/models.py:29 msgid "Token" -msgstr "" +msgstr "Token" #: authtoken/models.py:30 msgid "Tokens" -msgstr "" +msgstr "Tokens" #: authtoken/serializers.py:8 msgid "Username" -msgstr "" +msgstr "Brugernavn" #: authtoken/serializers.py:9 msgid "Password" -msgstr "" +msgstr "Kodeord" #: authtoken/serializers.py:20 msgid "User account is disabled." @@ -316,15 +316,15 @@ msgstr "Indsend." #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "stigende" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "faldende" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "Ugyldig side" #: pagination.py:427 msgid "Invalid cursor" @@ -426,7 +426,7 @@ msgstr "Ugyldig version i URL-stien." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Ugyldig version in URLen. Den stemmer ikke overens med nogen versionsnumre." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/de/LC_MESSAGES/django.po b/rest_framework/locale/de/LC_MESSAGES/django.po index 057a69f1c..725a0f757 100644 --- a/rest_framework/locale/de/LC_MESSAGES/django.po +++ b/rest_framework/locale/de/LC_MESSAGES/django.po @@ -4,6 +4,8 @@ # # Translators: # Fabian Büchler , 2015 +# datKater , 2017 +# Lukas Bischofberger , 2017 # Mads Jensen , 2015 # Niklas P , 2015-2016 # Thomas Tanner, 2015 @@ -14,8 +16,8 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Lukas Bischofberger \n" "Language-Team: German (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/de/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -74,7 +76,7 @@ msgstr "Benutzer" #: authtoken/models.py:20 msgid "Created" -msgstr "" +msgstr "Erzeugt" #: authtoken/models.py:29 msgid "Token" @@ -98,7 +100,7 @@ msgstr "Benutzerkonto ist gesperrt." #: authtoken/serializers.py:23 msgid "Unable to log in with provided credentials." -msgstr "Kann nicht mit den angegeben Zugangsdaten anmelden." +msgstr "Die angegebenen Zugangsdaten stimmen nicht." #: authtoken/serializers.py:26 msgid "Must include \"username\" and \"password\"." @@ -122,7 +124,7 @@ msgstr "Anmeldedaten fehlen." #: exceptions.py:99 msgid "You do not have permission to perform this action." -msgstr "Sie sind nicht berechtigt, diese Aktion durchzuführen." +msgstr "Sie sind nicht berechtigt diese Aktion durchzuführen." #: exceptions.py:104 views.py:81 msgid "Not found." @@ -151,7 +153,7 @@ msgstr "Dieses Feld ist erforderlich." #: fields.py:270 msgid "This field may not be null." -msgstr "Dieses Feld darf nicht Null sein." +msgstr "Dieses Feld darf nicht null sein." #: fields.py:608 fields.py:639 msgid "\"{input}\" is not a valid boolean." @@ -193,7 +195,7 @@ msgstr "\"{value}\" ist keine gültige UUID." #: fields.py:796 msgid "Enter a valid IPv4 or IPv6 address." -msgstr "Geben Sie eine gültige UPv4 oder IPv6 Adresse an" +msgstr "Geben Sie eine gültige IPv4 oder IPv6 Adresse an" #: fields.py:821 msgid "A valid integer is required." @@ -272,7 +274,7 @@ msgstr "Diese Auswahl darf nicht leer sein" #: fields.py:1339 msgid "\"{input}\" is not a valid path choice." -msgstr "\"{input}\" ist ein ungültiger Pfad Wahl." +msgstr "\"{input}\" ist ein ungültiger Pfad." #: fields.py:1358 msgid "No file was submitted." @@ -308,7 +310,7 @@ msgstr "Diese Liste darf nicht leer sein." #: fields.py:1502 msgid "Expected a dictionary of items but got type \"{input_type}\"." -msgstr "Erwarte ein Dictionary mit Elementen, erhielt aber den Typ \"{input_type}\"." +msgstr "Erwartete ein Dictionary mit Elementen, erhielt aber den Typ \"{input_type}\"." #: fields.py:1549 msgid "Value must be valid JSON." @@ -320,15 +322,15 @@ msgstr "Abschicken" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "Aufsteigend" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "Absteigend" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "Ungültige Seite." #: pagination.py:427 msgid "Invalid cursor" @@ -430,7 +432,7 @@ msgstr "Ungültige Version im URL Pfad." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Ungültige Version im URL-Pfad. Entspricht keinem Versions-Namensraum." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/el/LC_MESSAGES/django.po b/rest_framework/locale/el/LC_MESSAGES/django.po index be9bdf717..18eb371c9 100644 --- a/rest_framework/locale/el/LC_MESSAGES/django.po +++ b/rest_framework/locale/el/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Greek (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/el/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/es/LC_MESSAGES/django.po b/rest_framework/locale/es/LC_MESSAGES/django.po index b8a89aeb6..c9b6e9455 100644 --- a/rest_framework/locale/es/LC_MESSAGES/django.po +++ b/rest_framework/locale/es/LC_MESSAGES/django.po @@ -6,6 +6,7 @@ # Ernesto Rico-Schmidt , 2015 # José Padilla , 2015 # Miguel Gonzalez , 2015 +# Miguel Gonzalez , 2016 # Miguel Gonzalez , 2015-2016 # Sergio Infante , 2015 msgid "" @@ -13,8 +14,8 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Miguel Gonzalez \n" "Language-Team: Spanish (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -319,11 +320,11 @@ msgstr "Enviar" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "ascendiente" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "descendiente" #: pagination.py:193 msgid "Invalid page." @@ -429,7 +430,7 @@ msgstr "Versión inválida en la ruta de la URL." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "La versión especificada en la ruta de la URL no es válida. No coincide con ninguna del espacio de nombres de versiones." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/et/LC_MESSAGES/django.po b/rest_framework/locale/et/LC_MESSAGES/django.po index c9701cca7..cc2c2e3f0 100644 --- a/rest_framework/locale/et/LC_MESSAGES/django.po +++ b/rest_framework/locale/et/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Estonian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/et/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/fi/LC_MESSAGES/django.po b/rest_framework/locale/fi/LC_MESSAGES/django.po index bf1dd8c10..0791a3005 100644 --- a/rest_framework/locale/fi/LC_MESSAGES/django.po +++ b/rest_framework/locale/fi/LC_MESSAGES/django.po @@ -4,14 +4,14 @@ # # Translators: # Aarni Koskela, 2015 -# Aarni Koskela, 2015 +# Aarni Koskela, 2015-2016 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Aarni Koskela\n" "Language-Team: Finnish (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/fi/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -58,35 +58,35 @@ msgstr "Epäkelpo Token." #: authtoken/apps.py:7 msgid "Auth Token" -msgstr "" +msgstr "Autentikaatiotunniste" #: authtoken/models.py:15 msgid "Key" -msgstr "" +msgstr "Avain" #: authtoken/models.py:18 msgid "User" -msgstr "" +msgstr "Käyttäjä" #: authtoken/models.py:20 msgid "Created" -msgstr "" +msgstr "Luotu" #: authtoken/models.py:29 msgid "Token" -msgstr "" +msgstr "Tunniste" #: authtoken/models.py:30 msgid "Tokens" -msgstr "" +msgstr "Tunnisteet" #: authtoken/serializers.py:8 msgid "Username" -msgstr "" +msgstr "Käyttäjänimi" #: authtoken/serializers.py:9 msgid "Password" -msgstr "" +msgstr "Salasana" #: authtoken/serializers.py:20 msgid "User account is disabled." @@ -316,15 +316,15 @@ msgstr "Lähetä" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "nouseva" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "laskeva" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "Epäkelpo sivu." #: pagination.py:427 msgid "Invalid cursor" @@ -426,7 +426,7 @@ msgstr "Epäkelpo versio URL-polussa." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "URL-polun versio ei täsmää mihinkään versionimiavaruuteen." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/fr/LC_MESSAGES/django.po b/rest_framework/locale/fr/LC_MESSAGES/django.po index 284999a8b..25b39e453 100644 --- a/rest_framework/locale/fr/LC_MESSAGES/django.po +++ b/rest_framework/locale/fr/LC_MESSAGES/django.po @@ -12,8 +12,8 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Xavier Ordoquy \n" "Language-Team: French (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -318,11 +318,11 @@ msgstr "Envoyer" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "croissant" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "décroissant" #: pagination.py:193 msgid "Invalid page." @@ -428,7 +428,7 @@ msgstr "Version non valide dans l'URL." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Version invalide dans l'URL. Ne correspond à aucune version de l'espace de nommage." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/hu/LC_MESSAGES/django.po b/rest_framework/locale/hu/LC_MESSAGES/django.po index 7f3081fff..9002f8e61 100644 --- a/rest_framework/locale/hu/LC_MESSAGES/django.po +++ b/rest_framework/locale/hu/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Hungarian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/hu/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/it/LC_MESSAGES/django.po b/rest_framework/locale/it/LC_MESSAGES/django.po index 6a48c53a7..a48f8645d 100644 --- a/rest_framework/locale/it/LC_MESSAGES/django.po +++ b/rest_framework/locale/it/LC_MESSAGES/django.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Italian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/it/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/ja/LC_MESSAGES/django.po b/rest_framework/locale/ja/LC_MESSAGES/django.po index d2881dec9..a5e72d9a1 100644 --- a/rest_framework/locale/ja/LC_MESSAGES/django.po +++ b/rest_framework/locale/ja/LC_MESSAGES/django.po @@ -4,13 +4,14 @@ # # Translators: # Hiroaki Nakamura , 2016 +# Kouichi Nishizawa , 2017 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Kouichi Nishizawa \n" "Language-Team: Japanese (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ja/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -315,15 +316,15 @@ msgstr "提出" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "昇順" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "降順" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "不正なページです。" #: pagination.py:427 msgid "Invalid cursor" @@ -425,7 +426,7 @@ msgstr "URLパス内のバージョンが不正です。" #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "不正なバージョンのURLのパスです。どのバージョンの名前空間にも一致しません。" #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/ko_KR/LC_MESSAGES/django.po b/rest_framework/locale/ko_KR/LC_MESSAGES/django.po index 4ca53b3c3..152bc7b00 100644 --- a/rest_framework/locale/ko_KR/LC_MESSAGES/django.po +++ b/rest_framework/locale/ko_KR/LC_MESSAGES/django.po @@ -3,14 +3,15 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: +# Joon Hwan 김준환 , 2017 # SUN CHOI , 2015 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Joon Hwan 김준환 \n" "Language-Team: Korean (Korea) (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ko_KR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -247,7 +248,7 @@ msgstr "Time의 포멧이 잘못되었습니다. 이 형식들 중 한가지를 #: fields.py:1232 msgid "Duration has wrong format. Use one of these formats instead: {format}." -msgstr "" +msgstr "Duration의 포멧이 잘못되었습니다. 이 형식들 중 한가지를 사용하세요: {format}." #: fields.py:1251 fields.py:1300 msgid "\"{input}\" is not a valid choice." @@ -263,11 +264,11 @@ msgstr "아이템 리스트가 예상되었으나 \"{input_type}\"를 받았습 #: fields.py:1302 msgid "This selection may not be empty." -msgstr "" +msgstr "이 선택 항목은 비워 둘 수 없습니다." #: fields.py:1339 msgid "\"{input}\" is not a valid path choice." -msgstr "" +msgstr "\"{input}\"이 유효하지 않은 경로 선택입니다." #: fields.py:1358 msgid "No file was submitted." @@ -299,7 +300,7 @@ msgstr "유효한 이미지 파일을 업로드 하십시오. 업로드 하신 #: fields.py:1449 relations.py:438 serializers.py:525 msgid "This list may not be empty." -msgstr "" +msgstr "이 리스트는 비워 둘 수 없습니다." #: fields.py:1502 msgid "Expected a dictionary of items but got type \"{input_type}\"." @@ -307,7 +308,7 @@ msgstr "아이템 딕셔너리가 예상되었으나 \"{input_type}\" 타입을 #: fields.py:1549 msgid "Value must be valid JSON." -msgstr "" +msgstr "Value 는 유효한 JSON형식이어야 합니다." #: filters.py:36 templates/rest_framework/filters/django_filter.html:5 msgid "Submit" @@ -315,15 +316,15 @@ msgstr "" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "오름차순" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "내림차순" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "페이지가 유효하지 않습니다." #: pagination.py:427 msgid "Invalid cursor" @@ -381,7 +382,7 @@ msgstr "" #: templates/rest_framework/filters/search.html:2 msgid "Search" -msgstr "" +msgstr "검색" #: templates/rest_framework/horizontal/radio.html:2 #: templates/rest_framework/inline/radio.html:2 @@ -401,19 +402,19 @@ msgstr "이 칸은 반드시 고유해야 합니다." #: validators.py:97 msgid "The fields {field_names} must make a unique set." -msgstr "" +msgstr "{field_names} 필드는 반드시 고유하게 설정해야 합니다." #: validators.py:245 msgid "This field must be unique for the \"{date_field}\" date." -msgstr "" +msgstr "이 칸은 \"{date_field}\"날짜에 대해 고유해야합니다." #: validators.py:260 msgid "This field must be unique for the \"{date_field}\" month." -msgstr "" +msgstr "이 칸은 \"{date_field}\" 월에 대해 고유해야합니다." #: validators.py:273 msgid "This field must be unique for the \"{date_field}\" year." -msgstr "" +msgstr "이 칸은 \"{date_field}\" 년에 대해 고유해야합니다." #: versioning.py:42 msgid "Invalid version in \"Accept\" header." @@ -425,7 +426,7 @@ msgstr "URL path내 버전이 유효하지 않습니다." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "URL 경로에 유효하지 않은 버전이 있습니다. 버전 네임 스페이스와 일치하지 않습니다." #: versioning.py:147 msgid "Invalid version in hostname." @@ -437,4 +438,4 @@ msgstr "쿼리 파라메터내 버전이 유효하지 않습니다." #: views.py:88 msgid "Permission denied." -msgstr "" +msgstr "사용 권한이 거부되었습니다." diff --git a/rest_framework/locale/lv/LC_MESSAGES/django.po b/rest_framework/locale/lv/LC_MESSAGES/django.po new file mode 100644 index 000000000..2bc978866 --- /dev/null +++ b/rest_framework/locale/lv/LC_MESSAGES/django.po @@ -0,0 +1,440 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Translators: +# peterisb , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Django REST framework\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-07-12 16:13+0100\n" +"PO-Revision-Date: 2017-08-05 12:13+0000\n" +"Last-Translator: peterisb \n" +"Language-Team: Latvian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/lv/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: lv\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);\n" + +#: authentication.py:73 +msgid "Invalid basic header. No credentials provided." +msgstr "Nederīgs pieprasījuma sākums. Akreditācijas parametri nav nodrošināti." + +#: authentication.py:76 +msgid "Invalid basic header. Credentials string should not contain spaces." +msgstr "Nederīgs pieprasījuma sākums. Akreditācijas parametriem jābūt bez atstarpēm." + +#: authentication.py:82 +msgid "Invalid basic header. Credentials not correctly base64 encoded." +msgstr "Nederīgs pieprasījuma sākums. Akreditācijas parametri nav korekti base64 kodēti." + +#: authentication.py:99 +msgid "Invalid username/password." +msgstr "Nederīgs lietotājvārds/parole." + +#: authentication.py:102 authentication.py:198 +msgid "User inactive or deleted." +msgstr "Lietotājs neaktīvs vai dzēsts." + +#: authentication.py:176 +msgid "Invalid token header. No credentials provided." +msgstr "Nederīgs pilnvaras sākums. Akreditācijas parametri nav nodrošināti." + +#: authentication.py:179 +msgid "Invalid token header. Token string should not contain spaces." +msgstr "Nederīgs pilnvaras sākums. Pilnvaras parametros nevar būt tukšumi." + +#: authentication.py:185 +msgid "" +"Invalid token header. Token string should not contain invalid characters." +msgstr "Nederīgs pilnvaras sākums. Pilnvaras parametros nevar būt nederīgas zīmes." + +#: authentication.py:195 +msgid "Invalid token." +msgstr "Nederīga pilnavara." + +#: authtoken/apps.py:7 +msgid "Auth Token" +msgstr "Autorizācijas pilnvara" + +#: authtoken/models.py:15 +msgid "Key" +msgstr "Atslēga" + +#: authtoken/models.py:18 +msgid "User" +msgstr "Lietotājs" + +#: authtoken/models.py:20 +msgid "Created" +msgstr "Izveidots" + +#: authtoken/models.py:29 +msgid "Token" +msgstr "Pilnvara" + +#: authtoken/models.py:30 +msgid "Tokens" +msgstr "Pilnvaras" + +#: authtoken/serializers.py:8 +msgid "Username" +msgstr "Lietotājvārds" + +#: authtoken/serializers.py:9 +msgid "Password" +msgstr "Parole" + +#: authtoken/serializers.py:20 +msgid "User account is disabled." +msgstr "Lietotāja konts ir atslēgts." + +#: authtoken/serializers.py:23 +msgid "Unable to log in with provided credentials." +msgstr "Neiespējami pieteikties sistēmā ar nodrošinātajiem akreditācijas datiem." + +#: authtoken/serializers.py:26 +msgid "Must include \"username\" and \"password\"." +msgstr "Jābūt iekļautam \"username\" un \"password\"." + +#: exceptions.py:49 +msgid "A server error occurred." +msgstr "Notikusi servera kļūda." + +#: exceptions.py:84 +msgid "Malformed request." +msgstr "Nenoformēts pieprasījums." + +#: exceptions.py:89 +msgid "Incorrect authentication credentials." +msgstr "Nekorekti autentifikācijas parametri." + +#: exceptions.py:94 +msgid "Authentication credentials were not provided." +msgstr "Netika nodrošināti autorizācijas parametri." + +#: exceptions.py:99 +msgid "You do not have permission to perform this action." +msgstr "Tev nav tiesību veikt šo darbību." + +#: exceptions.py:104 views.py:81 +msgid "Not found." +msgstr "Nav atrasts." + +#: exceptions.py:109 +msgid "Method \"{method}\" not allowed." +msgstr "Metode \"{method}\" nav atļauta." + +#: exceptions.py:120 +msgid "Could not satisfy the request Accept header." +msgstr "Nevarēja apmierināt pieprasījuma Accept header." + +#: exceptions.py:132 +msgid "Unsupported media type \"{media_type}\" in request." +msgstr "Pieprasījumā neatbalstīts datu tips \"{media_type}\" ." + +#: exceptions.py:145 +msgid "Request was throttled." +msgstr "Pieprasījums tika apturēts." + +#: fields.py:269 relations.py:206 relations.py:239 validators.py:98 +#: validators.py:181 +msgid "This field is required." +msgstr "Šis lauks ir obligāts." + +#: fields.py:270 +msgid "This field may not be null." +msgstr "Šis lauks nevar būt null." + +#: fields.py:608 fields.py:639 +msgid "\"{input}\" is not a valid boolean." +msgstr "\"{input}\" ir nederīga loģiskā vērtība." + +#: fields.py:674 +msgid "This field may not be blank." +msgstr "Šis lauks nevar būt tukšs." + +#: fields.py:675 fields.py:1675 +msgid "Ensure this field has no more than {max_length} characters." +msgstr "Pārliecinies, ka laukā nav vairāk par {max_length} zīmēm." + +#: fields.py:676 +msgid "Ensure this field has at least {min_length} characters." +msgstr "Pārliecinies, ka laukā ir vismaz {min_length} zīmes." + +#: fields.py:713 +msgid "Enter a valid email address." +msgstr "Ievadi derīgu e-pasta adresi." + +#: fields.py:724 +msgid "This value does not match the required pattern." +msgstr "Šī vērtība neatbilst prasītajam pierakstam." + +#: fields.py:735 +msgid "" +"Enter a valid \"slug\" consisting of letters, numbers, underscores or " +"hyphens." +msgstr "Ievadi derīgu \"slug\" vērtību, kura sastāv no burtiem, skaitļiem, apakš-svītras vai defises." + +#: fields.py:747 +msgid "Enter a valid URL." +msgstr "Ievadi derīgu URL." + +#: fields.py:760 +msgid "\"{value}\" is not a valid UUID." +msgstr "\"{value}\" ir nedrīgs UUID." + +#: fields.py:796 +msgid "Enter a valid IPv4 or IPv6 address." +msgstr "Ievadi derīgu IPv4 vai IPv6 adresi." + +#: fields.py:821 +msgid "A valid integer is required." +msgstr "Prasīta ir derīga skaitliska vērtība." + +#: fields.py:822 fields.py:857 fields.py:891 +msgid "Ensure this value is less than or equal to {max_value}." +msgstr "Pārliecinies, ka šī vērtība ir mazāka vai vienāda ar {max_value}." + +#: fields.py:823 fields.py:858 fields.py:892 +msgid "Ensure this value is greater than or equal to {min_value}." +msgstr "Pārliecinies, ka šī vērtība ir lielāka vai vienāda ar {min_value}." + +#: fields.py:824 fields.py:859 fields.py:896 +msgid "String value too large." +msgstr "Teksta vērtība pārāk liela." + +#: fields.py:856 fields.py:890 +msgid "A valid number is required." +msgstr "Derīgs skaitlis ir prasīts." + +#: fields.py:893 +msgid "Ensure that there are no more than {max_digits} digits in total." +msgstr "Pārliecinies, ka nav vairāk par {max_digits} zīmēm kopā." + +#: fields.py:894 +msgid "" +"Ensure that there are no more than {max_decimal_places} decimal places." +msgstr "Pārliecinies, ka nav vairāk par {max_decimal_places} decimālajām zīmēm." + +#: fields.py:895 +msgid "" +"Ensure that there are no more than {max_whole_digits} digits before the " +"decimal point." +msgstr "Pārliecinies, ka nav vairāk par {max_whole_digits} zīmēm pirms komata." + +#: fields.py:1025 +msgid "Datetime has wrong format. Use one of these formats instead: {format}." +msgstr "Datuma un laika formāts ir nepareizs. Lieto vienu no norādītajiem formātiem: \"{format}.\"" + +#: fields.py:1026 +msgid "Expected a datetime but got a date." +msgstr "Tika gaidīts datums un laiks, saņemts datums.." + +#: fields.py:1103 +msgid "Date has wrong format. Use one of these formats instead: {format}." +msgstr "Datumam ir nepareizs formāts. Lieto vienu no norādītajiem formātiem: {format}." + +#: fields.py:1104 +msgid "Expected a date but got a datetime." +msgstr "Tika gaidīts datums, saņemts datums un laiks." + +#: fields.py:1170 +msgid "Time has wrong format. Use one of these formats instead: {format}." +msgstr "Laikam ir nepareizs formāts. Lieto vienu no norādītajiem formātiem: {format}." + +#: fields.py:1232 +msgid "Duration has wrong format. Use one of these formats instead: {format}." +msgstr "Ilgumam ir nepreizs formāts. Lieto vienu no norādītajiem formātiem: {format}." + +#: fields.py:1251 fields.py:1300 +msgid "\"{input}\" is not a valid choice." +msgstr "\"{input}\" ir nederīga izvēle." + +#: fields.py:1254 relations.py:71 relations.py:441 +msgid "More than {count} items..." +msgstr "Vairāk par {count} ierakstiem..." + +#: fields.py:1301 fields.py:1448 relations.py:437 serializers.py:524 +msgid "Expected a list of items but got type \"{input_type}\"." +msgstr "Tika gaidīts saraksts ar ierakstiem, bet tika saņemts \"{input_type}\" tips." + +#: fields.py:1302 +msgid "This selection may not be empty." +msgstr "Šī daļa nevar būt tukša." + +#: fields.py:1339 +msgid "\"{input}\" is not a valid path choice." +msgstr "\"{input}\" ir nederīga ceļa izvēle." + +#: fields.py:1358 +msgid "No file was submitted." +msgstr "Neviens fails netika pievienots." + +#: fields.py:1359 +msgid "" +"The submitted data was not a file. Check the encoding type on the form." +msgstr "Pievienotie dati nebija fails. Pārbaudi kodējuma tipu formā." + +#: fields.py:1360 +msgid "No filename could be determined." +msgstr "Faila nosaukums nevar tikt noteikts." + +#: fields.py:1361 +msgid "The submitted file is empty." +msgstr "Pievienotais fails ir tukšs." + +#: fields.py:1362 +msgid "" +"Ensure this filename has at most {max_length} characters (it has {length})." +msgstr "Pārliecinies, ka faila nosaukumā ir vismaz {max_length} zīmes (tajā ir {length})." + +#: fields.py:1410 +msgid "" +"Upload a valid image. The file you uploaded was either not an image or a " +"corrupted image." +msgstr "Augšupielādē derīgu attēlu. Pievienotā datne nebija attēls vai bojāts attēls." + +#: fields.py:1449 relations.py:438 serializers.py:525 +msgid "This list may not be empty." +msgstr "Šis saraksts nevar būt tukšs." + +#: fields.py:1502 +msgid "Expected a dictionary of items but got type \"{input_type}\"." +msgstr "Tika gaidīta vārdnīca ar ierakstiem, bet tika saņemts \"{input_type}\" tips." + +#: fields.py:1549 +msgid "Value must be valid JSON." +msgstr "Vērtībai ir jābūt derīgam JSON." + +#: filters.py:36 templates/rest_framework/filters/django_filter.html:5 +msgid "Submit" +msgstr "Iesniegt" + +#: filters.py:336 +msgid "ascending" +msgstr "augoši" + +#: filters.py:337 +msgid "descending" +msgstr "dilstoši" + +#: pagination.py:193 +msgid "Invalid page." +msgstr "Nederīga lapa." + +#: pagination.py:427 +msgid "Invalid cursor" +msgstr "Nederīgs kursors" + +#: relations.py:207 +msgid "Invalid pk \"{pk_value}\" - object does not exist." +msgstr "Nederīga pk \"{pk_value}\" - objekts neeksistē." + +#: relations.py:208 +msgid "Incorrect type. Expected pk value, received {data_type}." +msgstr "Nepareizs tips. Tika gaidīta pk vērtība, saņemts {data_type}." + +#: relations.py:240 +msgid "Invalid hyperlink - No URL match." +msgstr "Nederīga hipersaite - Nav URL sakritība." + +#: relations.py:241 +msgid "Invalid hyperlink - Incorrect URL match." +msgstr "Nederīga hipersaite - Nederīga URL sakritība." + +#: relations.py:242 +msgid "Invalid hyperlink - Object does not exist." +msgstr "Nederīga hipersaite - Objekts neeksistē." + +#: relations.py:243 +msgid "Incorrect type. Expected URL string, received {data_type}." +msgstr "Nepareizs tips. Tika gaidīts URL teksts, saņemts {data_type}." + +#: relations.py:401 +msgid "Object with {slug_name}={value} does not exist." +msgstr "Objekts ar {slug_name}={value} neeksistē." + +#: relations.py:402 +msgid "Invalid value." +msgstr "Nedrīga vērtība." + +#: serializers.py:326 +msgid "Invalid data. Expected a dictionary, but got {datatype}." +msgstr "Nederīgi dati. Tika gaidīta vārdnīca, saņemts {datatype}." + +#: templates/rest_framework/admin.html:116 +#: templates/rest_framework/base.html:128 +msgid "Filters" +msgstr "Filtri" + +#: templates/rest_framework/filters/django_filter.html:2 +#: templates/rest_framework/filters/django_filter_crispyforms.html:4 +msgid "Field filters" +msgstr "Lauka filtri" + +#: templates/rest_framework/filters/ordering.html:3 +msgid "Ordering" +msgstr "Kārtošana" + +#: templates/rest_framework/filters/search.html:2 +msgid "Search" +msgstr "Meklēt" + +#: templates/rest_framework/horizontal/radio.html:2 +#: templates/rest_framework/inline/radio.html:2 +#: templates/rest_framework/vertical/radio.html:2 +msgid "None" +msgstr "Nekas" + +#: templates/rest_framework/horizontal/select_multiple.html:2 +#: templates/rest_framework/inline/select_multiple.html:2 +#: templates/rest_framework/vertical/select_multiple.html:2 +msgid "No items to select." +msgstr "Nav ierakstu, ko izvēlēties." + +#: validators.py:43 +msgid "This field must be unique." +msgstr "Šim laukam ir jābūt unikālam." + +#: validators.py:97 +msgid "The fields {field_names} must make a unique set." +msgstr "Laukiem {field_names} jāveido unikālas kombinācijas." + +#: validators.py:245 +msgid "This field must be unique for the \"{date_field}\" date." +msgstr "Šim laukam ir jābūt unikālam priekš \"{date_field}\" datuma." + +#: validators.py:260 +msgid "This field must be unique for the \"{date_field}\" month." +msgstr "Šim laukam ir jābūt unikālam priekš \"{date_field}\" mēneša." + +#: validators.py:273 +msgid "This field must be unique for the \"{date_field}\" year." +msgstr "Šim laukam ir jābūt unikālam priekš \"{date_field}\" gada." + +#: versioning.py:42 +msgid "Invalid version in \"Accept\" header." +msgstr "Nederīga versija \"Accept\" galvenē." + +#: versioning.py:73 +msgid "Invalid version in URL path." +msgstr "Nederīga versija URL ceļā." + +#: versioning.py:115 +msgid "Invalid version in URL path. Does not match any version namespace." +msgstr "Nederīga versija URL ceļā. Nav atbilstības esošo versiju telpā." + +#: versioning.py:147 +msgid "Invalid version in hostname." +msgstr "Nederīga versija servera nosaukumā." + +#: versioning.py:169 +msgid "Invalid version in query parameter." +msgstr "Nederīga versija pieprasījuma parametros." + +#: views.py:88 +msgid "Permission denied." +msgstr "Pieeja liegta." diff --git a/rest_framework/locale/mk/LC_MESSAGES/django.po b/rest_framework/locale/mk/LC_MESSAGES/django.po index d53a30677..0e59663d0 100644 --- a/rest_framework/locale/mk/LC_MESSAGES/django.po +++ b/rest_framework/locale/mk/LC_MESSAGES/django.po @@ -3,14 +3,14 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: -# Filip Dimitrovski , 2015 +# Filip Dimitrovski , 2015-2016 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Filip Dimitrovski \n" "Language-Team: Macedonian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/mk/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -57,7 +57,7 @@ msgstr "Невалиден токен." #: authtoken/apps.py:7 msgid "Auth Token" -msgstr "" +msgstr "Автентикациски токен" #: authtoken/models.py:15 msgid "Key" @@ -65,7 +65,7 @@ msgstr "" #: authtoken/models.py:18 msgid "User" -msgstr "" +msgstr "Корисник" #: authtoken/models.py:20 msgid "Created" @@ -73,19 +73,19 @@ msgstr "" #: authtoken/models.py:29 msgid "Token" -msgstr "" +msgstr "Токен" #: authtoken/models.py:30 msgid "Tokens" -msgstr "" +msgstr "Токени" #: authtoken/serializers.py:8 msgid "Username" -msgstr "" +msgstr "Корисничко име" #: authtoken/serializers.py:9 msgid "Password" -msgstr "" +msgstr "Лозинка" #: authtoken/serializers.py:20 msgid "User account is disabled." @@ -184,11 +184,11 @@ msgstr "Внесете валиден URL." #: fields.py:760 msgid "\"{value}\" is not a valid UUID." -msgstr "" +msgstr "\"{value}\" не е валиден UUID." #: fields.py:796 msgid "Enter a valid IPv4 or IPv6 address." -msgstr "" +msgstr "Внеси валидна IPv4 или IPv6 адреса." #: fields.py:821 msgid "A valid integer is required." @@ -255,11 +255,11 @@ msgstr "„{input}“ не е валиден избор." #: fields.py:1254 relations.py:71 relations.py:441 msgid "More than {count} items..." -msgstr "" +msgstr "Повеќе од {count} ставки..." #: fields.py:1301 fields.py:1448 relations.py:437 serializers.py:524 msgid "Expected a list of items but got type \"{input_type}\"." -msgstr "Очекувана беше листа, а внесено беше „{input_type}“." +msgstr "Очекувана беше листа од ставки, а внесено беше „{input_type}“." #: fields.py:1302 msgid "This selection may not be empty." @@ -299,35 +299,35 @@ msgstr "Качете (upload-ирајте) валидна слика. Фајло #: fields.py:1449 relations.py:438 serializers.py:525 msgid "This list may not be empty." -msgstr "" +msgstr "Оваа листа не смее да биде празна." #: fields.py:1502 msgid "Expected a dictionary of items but got type \"{input_type}\"." -msgstr "" +msgstr "Очекуван беше dictionary од ставки, a внесен беше тип \"{input_type}\"." #: fields.py:1549 msgid "Value must be valid JSON." -msgstr "" +msgstr "Вредноста мора да биде валиден JSON." #: filters.py:36 templates/rest_framework/filters/django_filter.html:5 msgid "Submit" -msgstr "" +msgstr "Испрати" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "растечки" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "опаѓачки" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "Невалидна вредност за страна." #: pagination.py:427 msgid "Invalid cursor" -msgstr "" +msgstr "Невалиден покажувач (cursor)" #: relations.py:207 msgid "Invalid pk \"{pk_value}\" - object does not exist." @@ -368,32 +368,32 @@ msgstr "Невалидни податоци. Очекуван беше dictionar #: templates/rest_framework/admin.html:116 #: templates/rest_framework/base.html:128 msgid "Filters" -msgstr "" +msgstr "Филтри" #: templates/rest_framework/filters/django_filter.html:2 #: templates/rest_framework/filters/django_filter_crispyforms.html:4 msgid "Field filters" -msgstr "" +msgstr "Филтри на полиња" #: templates/rest_framework/filters/ordering.html:3 msgid "Ordering" -msgstr "" +msgstr "Подредување" #: templates/rest_framework/filters/search.html:2 msgid "Search" -msgstr "" +msgstr "Пребарај" #: templates/rest_framework/horizontal/radio.html:2 #: templates/rest_framework/inline/radio.html:2 #: templates/rest_framework/vertical/radio.html:2 msgid "None" -msgstr "" +msgstr "Ништо" #: templates/rest_framework/horizontal/select_multiple.html:2 #: templates/rest_framework/inline/select_multiple.html:2 #: templates/rest_framework/vertical/select_multiple.html:2 msgid "No items to select." -msgstr "" +msgstr "Нема ставки за избирање." #: validators.py:43 msgid "This field must be unique." @@ -425,7 +425,7 @@ msgstr "Невалидна верзија во URL патеката." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Верзијата во URL патеката не е валидна. Не се согласува со ниеден version namespace (именски простор за верзии)." #: versioning.py:147 msgid "Invalid version in hostname." @@ -437,4 +437,4 @@ msgstr "Невалидна верзија во query параметарот." #: views.py:88 msgid "Permission denied." -msgstr "" +msgstr "Барањето не е дозволено." diff --git a/rest_framework/locale/nb/LC_MESSAGES/django.po b/rest_framework/locale/nb/LC_MESSAGES/django.po index 634a24642..f9ecada63 100644 --- a/rest_framework/locale/nb/LC_MESSAGES/django.po +++ b/rest_framework/locale/nb/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Norwegian Bokmål (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/nb/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/nl/LC_MESSAGES/django.po b/rest_framework/locale/nl/LC_MESSAGES/django.po index 6b9dd127b..370f3aa41 100644 --- a/rest_framework/locale/nl/LC_MESSAGES/django.po +++ b/rest_framework/locale/nl/LC_MESSAGES/django.po @@ -4,16 +4,17 @@ # # Translators: # Hans van Luttikhuizen , 2016 -# mikedingjan , 2015 -# mikedingjan , 2015 +# Mike Dingjan , 2015 +# Mike Dingjan , 2017 +# Mike Dingjan , 2015 # Hans van Luttikhuizen , 2016 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Mike Dingjan \n" "Language-Team: Dutch (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/nl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -318,11 +319,11 @@ msgstr "Verzenden" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "oplopend" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "aflopend" #: pagination.py:193 msgid "Invalid page." @@ -428,7 +429,7 @@ msgstr "Ongeldige versie in URL-pad." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Ongeldige versie in het URL pad, komt niet overeen met een geldige versie namespace" #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/pl/LC_MESSAGES/django.po b/rest_framework/locale/pl/LC_MESSAGES/django.po index b8592e9b7..611426556 100644 --- a/rest_framework/locale/pl/LC_MESSAGES/django.po +++ b/rest_framework/locale/pl/LC_MESSAGES/django.po @@ -5,20 +5,21 @@ # Translators: # Janusz Harkot , 2015 # Piotr Jakimiak , 2015 +# m_aciek , 2016 # m_aciek , 2015-2016 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: m_aciek \n" "Language-Team: Polish (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/pl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pl\n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n" #: authentication.py:73 msgid "Invalid basic header. No credentials provided." @@ -317,11 +318,11 @@ msgstr "Wyślij" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "rosnąco" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "malejąco" #: pagination.py:193 msgid "Invalid page." @@ -427,7 +428,7 @@ msgstr "Błędna wersja w ścieżce URL." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Niepoprawna wersja w ścieżce URL. Nie pasuje do przestrzeni nazw żadnej wersji." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/pt_BR/LC_MESSAGES/django.po b/rest_framework/locale/pt_BR/LC_MESSAGES/django.po index 2c90f14ca..3a57b6770 100644 --- a/rest_framework/locale/pt_BR/LC_MESSAGES/django.po +++ b/rest_framework/locale/pt_BR/LC_MESSAGES/django.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/pt_BR/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/ro/LC_MESSAGES/django.po b/rest_framework/locale/ro/LC_MESSAGES/django.po index bb3b5e3c0..d144d847e 100644 --- a/rest_framework/locale/ro/LC_MESSAGES/django.po +++ b/rest_framework/locale/ro/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Romanian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ro/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/ru/LC_MESSAGES/django.po b/rest_framework/locale/ru/LC_MESSAGES/django.po index b73270906..7e09b227e 100644 --- a/rest_framework/locale/ru/LC_MESSAGES/django.po +++ b/rest_framework/locale/ru/LC_MESSAGES/django.po @@ -3,6 +3,7 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: +# Grigory Mishchenko , 2017 # Kirill Tarasenko, 2015 # koodjo , 2015 # Mike TUMS , 2015 @@ -12,8 +13,8 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Grigory Mishchenko \n" "Language-Team: Russian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ru/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -161,11 +162,11 @@ msgstr "Это поле не может быть пустым." #: fields.py:675 fields.py:1675 msgid "Ensure this field has no more than {max_length} characters." -msgstr "Убедитесь что в этом поле не больше {max_length} символов." +msgstr "Убедитесь, что в этом поле не больше {max_length} символов." #: fields.py:676 msgid "Ensure this field has at least {min_length} characters." -msgstr "Убедитесь что в этом поле как минимум {min_length} символов." +msgstr "Убедитесь, что в этом поле как минимум {min_length} символов." #: fields.py:713 msgid "Enter a valid email address." @@ -199,11 +200,11 @@ msgstr "Требуется целочисленное значение." #: fields.py:822 fields.py:857 fields.py:891 msgid "Ensure this value is less than or equal to {max_value}." -msgstr "Убедитесь что значение меньше или равно {max_value}." +msgstr "Убедитесь, что значение меньше или равно {max_value}." #: fields.py:823 fields.py:858 fields.py:892 msgid "Ensure this value is greater than or equal to {min_value}." -msgstr "Убедитесь что значение больше или равно {min_value}." +msgstr "Убедитесь, что значение больше или равно {min_value}." #: fields.py:824 fields.py:859 fields.py:896 msgid "String value too large." @@ -215,18 +216,18 @@ msgstr "Требуется численное значение." #: fields.py:893 msgid "Ensure that there are no more than {max_digits} digits in total." -msgstr "Убедитесь что в числе не больше {max_digits} знаков." +msgstr "Убедитесь, что в числе не больше {max_digits} знаков." #: fields.py:894 msgid "" "Ensure that there are no more than {max_decimal_places} decimal places." -msgstr "Убедитесь что в числе не больше {max_decimal_places} знаков в дробной части." +msgstr "Убедитесь, что в числе не больше {max_decimal_places} знаков в дробной части." #: fields.py:895 msgid "" "Ensure that there are no more than {max_whole_digits} digits before the " "decimal point." -msgstr "Убедитесь что в цисле не больше {max_whole_digits} знаков в целой части." +msgstr "Убедитесь, что в числе не больше {max_whole_digits} знаков в целой части." #: fields.py:1025 msgid "Datetime has wrong format. Use one of these formats instead: {format}." @@ -279,7 +280,7 @@ msgstr "Не был загружен файл." #: fields.py:1359 msgid "" "The submitted data was not a file. Check the encoding type on the form." -msgstr "Загруженный файл не является корректным файлом. " +msgstr "Загруженный файл не является корректным файлом." #: fields.py:1360 msgid "No filename could be determined." @@ -292,7 +293,7 @@ msgstr "Загруженный файл пуст." #: fields.py:1362 msgid "" "Ensure this filename has at most {max_length} characters (it has {length})." -msgstr "Убедитесь что имя файла меньше {max_length} символов (сейчас {length})." +msgstr "Убедитесь, что имя файла меньше {max_length} символов (сейчас {length})." #: fields.py:1410 msgid "" @@ -338,7 +339,7 @@ msgstr "Недопустимый первичный ключ \"{pk_value}\" - о #: relations.py:208 msgid "Incorrect type. Expected pk value, received {data_type}." -msgstr "Некорректный тип. Ожилалось значение первичного ключа, получен {data_type}." +msgstr "Некорректный тип. Ожидалось значение первичного ключа, получен {data_type}." #: relations.py:240 msgid "Invalid hyperlink - No URL match." diff --git a/rest_framework/locale/sk/LC_MESSAGES/django.po b/rest_framework/locale/sk/LC_MESSAGES/django.po index 1c22d09f0..119430e90 100644 --- a/rest_framework/locale/sk/LC_MESSAGES/django.po +++ b/rest_framework/locale/sk/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Slovak (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/sk/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/sl/LC_MESSAGES/django.po b/rest_framework/locale/sl/LC_MESSAGES/django.po new file mode 100644 index 000000000..9af0fc8fc --- /dev/null +++ b/rest_framework/locale/sl/LC_MESSAGES/django.po @@ -0,0 +1,440 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Translators: +# Gregor Cimerman, 2017 +msgid "" +msgstr "" +"Project-Id-Version: Django REST framework\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-07-12 16:13+0100\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Gregor Cimerman\n" +"Language-Team: Slovenian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#: authentication.py:73 +msgid "Invalid basic header. No credentials provided." +msgstr "Napačno enostavno zagalvje. Ni podanih poverilnic." + +#: authentication.py:76 +msgid "Invalid basic header. Credentials string should not contain spaces." +msgstr "Napačno enostavno zaglavje. Poverilniški niz ne sme vsebovati presledkov." + +#: authentication.py:82 +msgid "Invalid basic header. Credentials not correctly base64 encoded." +msgstr "Napačno enostavno zaglavje. Poverilnice niso pravilno base64 kodirane." + +#: authentication.py:99 +msgid "Invalid username/password." +msgstr "Napačno uporabniško ime ali geslo." + +#: authentication.py:102 authentication.py:198 +msgid "User inactive or deleted." +msgstr "Uporabnik neaktiven ali izbrisan." + +#: authentication.py:176 +msgid "Invalid token header. No credentials provided." +msgstr "Neveljaven žeton v zaglavju. Ni vsebovanih poverilnic." + +#: authentication.py:179 +msgid "Invalid token header. Token string should not contain spaces." +msgstr "Neveljaven žeton v zaglavju. Žeton ne sme vsebovati presledkov." + +#: authentication.py:185 +msgid "" +"Invalid token header. Token string should not contain invalid characters." +msgstr "Neveljaven žeton v zaglavju. Žeton ne sme vsebovati napačnih znakov." + +#: authentication.py:195 +msgid "Invalid token." +msgstr "Neveljaven žeton." + +#: authtoken/apps.py:7 +msgid "Auth Token" +msgstr "Prijavni žeton" + +#: authtoken/models.py:15 +msgid "Key" +msgstr "Ključ" + +#: authtoken/models.py:18 +msgid "User" +msgstr "Uporabnik" + +#: authtoken/models.py:20 +msgid "Created" +msgstr "Ustvarjen" + +#: authtoken/models.py:29 +msgid "Token" +msgstr "Žeton" + +#: authtoken/models.py:30 +msgid "Tokens" +msgstr "Žetoni" + +#: authtoken/serializers.py:8 +msgid "Username" +msgstr "Uporabniško ime" + +#: authtoken/serializers.py:9 +msgid "Password" +msgstr "Geslo" + +#: authtoken/serializers.py:20 +msgid "User account is disabled." +msgstr "Uporabniški račun je onemogočen." + +#: authtoken/serializers.py:23 +msgid "Unable to log in with provided credentials." +msgstr "Neuspešna prijava s podanimi poverilnicami." + +#: authtoken/serializers.py:26 +msgid "Must include \"username\" and \"password\"." +msgstr "Mora vsebovati \"uporabniško ime\" in \"geslo\"." + +#: exceptions.py:49 +msgid "A server error occurred." +msgstr "Napaka na strežniku." + +#: exceptions.py:84 +msgid "Malformed request." +msgstr "Okvarjen zahtevek." + +#: exceptions.py:89 +msgid "Incorrect authentication credentials." +msgstr "Napačni avtentikacijski podatki." + +#: exceptions.py:94 +msgid "Authentication credentials were not provided." +msgstr "Avtentikacijski podatki niso bili podani." + +#: exceptions.py:99 +msgid "You do not have permission to perform this action." +msgstr "Nimate dovoljenj za izvedbo te akcije." + +#: exceptions.py:104 views.py:81 +msgid "Not found." +msgstr "Ni najdeno" + +#: exceptions.py:109 +msgid "Method \"{method}\" not allowed." +msgstr "Metoda \"{method}\" ni dovoljena" + +#: exceptions.py:120 +msgid "Could not satisfy the request Accept header." +msgstr "Ni bilo mogoče zagotoviti zaglavja Accept zahtevka." + +#: exceptions.py:132 +msgid "Unsupported media type \"{media_type}\" in request." +msgstr "Nepodprt medijski tip \"{media_type}\" v zahtevku." + +#: exceptions.py:145 +msgid "Request was throttled." +msgstr "Zahtevek je bil pridržan." + +#: fields.py:269 relations.py:206 relations.py:239 validators.py:98 +#: validators.py:181 +msgid "This field is required." +msgstr "To polje je obvezno." + +#: fields.py:270 +msgid "This field may not be null." +msgstr "To polje ne sme biti null." + +#: fields.py:608 fields.py:639 +msgid "\"{input}\" is not a valid boolean." +msgstr "\"{input}\" ni veljaven boolean." + +#: fields.py:674 +msgid "This field may not be blank." +msgstr "To polje ne sme biti prazno." + +#: fields.py:675 fields.py:1675 +msgid "Ensure this field has no more than {max_length} characters." +msgstr "To polje ne sme biti daljše od {max_length} znakov." + +#: fields.py:676 +msgid "Ensure this field has at least {min_length} characters." +msgstr "To polje mora vsebovati vsaj {min_length} znakov." + +#: fields.py:713 +msgid "Enter a valid email address." +msgstr "Vnesite veljaven elektronski naslov." + +#: fields.py:724 +msgid "This value does not match the required pattern." +msgstr "Ta vrednost ne ustreza zahtevanemu vzorcu." + +#: fields.py:735 +msgid "" +"Enter a valid \"slug\" consisting of letters, numbers, underscores or " +"hyphens." +msgstr "Vnesite veljaven \"slug\", ki vsebuje črke, številke, podčrtaje ali vezaje." + +#: fields.py:747 +msgid "Enter a valid URL." +msgstr "Vnesite veljaven URL." + +#: fields.py:760 +msgid "\"{value}\" is not a valid UUID." +msgstr "\"{value}\" ni veljaven UUID" + +#: fields.py:796 +msgid "Enter a valid IPv4 or IPv6 address." +msgstr "Vnesite veljaven IPv4 ali IPv6 naslov." + +#: fields.py:821 +msgid "A valid integer is required." +msgstr "Zahtevano je veljavno celo število." + +#: fields.py:822 fields.py:857 fields.py:891 +msgid "Ensure this value is less than or equal to {max_value}." +msgstr "Vrednost mora biti manjša ali enaka {max_value}." + +#: fields.py:823 fields.py:858 fields.py:892 +msgid "Ensure this value is greater than or equal to {min_value}." +msgstr "Vrednost mora biti večija ali enaka {min_value}." + +#: fields.py:824 fields.py:859 fields.py:896 +msgid "String value too large." +msgstr "Niz je prevelik." + +#: fields.py:856 fields.py:890 +msgid "A valid number is required." +msgstr "Zahtevano je veljavno število." + +#: fields.py:893 +msgid "Ensure that there are no more than {max_digits} digits in total." +msgstr "Vnesete lahko največ {max_digits} števk." + +#: fields.py:894 +msgid "" +"Ensure that there are no more than {max_decimal_places} decimal places." +msgstr "Vnesete lahko največ {max_decimal_places} decimalnih mest." + +#: fields.py:895 +msgid "" +"Ensure that there are no more than {max_whole_digits} digits before the " +"decimal point." +msgstr "Vnesete lahko največ {max_whole_digits} števk pred decimalno piko." + +#: fields.py:1025 +msgid "Datetime has wrong format. Use one of these formats instead: {format}." +msgstr "Datim in čas v napačnem formatu. Uporabite eno izmed naslednjih formatov: {format}." + +#: fields.py:1026 +msgid "Expected a datetime but got a date." +msgstr "Pričakovan datum in čas, prejet le datum." + +#: fields.py:1103 +msgid "Date has wrong format. Use one of these formats instead: {format}." +msgstr "Datum je v napačnem formatu. Uporabnite enega izmed naslednjih: {format}." + +#: fields.py:1104 +msgid "Expected a date but got a datetime." +msgstr "Pričakovan datum vendar prejet datum in čas." + +#: fields.py:1170 +msgid "Time has wrong format. Use one of these formats instead: {format}." +msgstr "Čas je v napačnem formatu. Uporabite enega izmed naslednjih: {format}." + +#: fields.py:1232 +msgid "Duration has wrong format. Use one of these formats instead: {format}." +msgstr "Trajanje je v napačnem formatu. Uporabite enega izmed naslednjih: {format}." + +#: fields.py:1251 fields.py:1300 +msgid "\"{input}\" is not a valid choice." +msgstr "\"{input}\" ni veljavna izbira." + +#: fields.py:1254 relations.py:71 relations.py:441 +msgid "More than {count} items..." +msgstr "Več kot {count} elementov..." + +#: fields.py:1301 fields.py:1448 relations.py:437 serializers.py:524 +msgid "Expected a list of items but got type \"{input_type}\"." +msgstr "Pričakovan seznam elementov vendar prejet tip \"{input_type}\"." + +#: fields.py:1302 +msgid "This selection may not be empty." +msgstr "Ta izbria ne sme ostati prazna." + +#: fields.py:1339 +msgid "\"{input}\" is not a valid path choice." +msgstr "\"{input}\" ni veljavna izbira poti." + +#: fields.py:1358 +msgid "No file was submitted." +msgstr "Datoteka ni bila oddana." + +#: fields.py:1359 +msgid "" +"The submitted data was not a file. Check the encoding type on the form." +msgstr "Oddani podatki niso datoteka. Preverite vrsto kodiranja na formi." + +#: fields.py:1360 +msgid "No filename could be determined." +msgstr "Imena datoteke ni bilo mogoče določiti." + +#: fields.py:1361 +msgid "The submitted file is empty." +msgstr "Oddana datoteka je prazna." + +#: fields.py:1362 +msgid "" +"Ensure this filename has at most {max_length} characters (it has {length})." +msgstr "Ime datoteke lahko vsebuje največ {max_length} znakov (ta jih ima {length})." + +#: fields.py:1410 +msgid "" +"Upload a valid image. The file you uploaded was either not an image or a " +"corrupted image." +msgstr "Naložite veljavno sliko. Naložena datoteka ni bila slika ali pa je okvarjena." + +#: fields.py:1449 relations.py:438 serializers.py:525 +msgid "This list may not be empty." +msgstr "Seznam ne sme biti prazen." + +#: fields.py:1502 +msgid "Expected a dictionary of items but got type \"{input_type}\"." +msgstr "Pričakovan je slovar elementov, prejet element je tipa \"{input_type}\"." + +#: fields.py:1549 +msgid "Value must be valid JSON." +msgstr "Vrednost mora biti veljaven JSON." + +#: filters.py:36 templates/rest_framework/filters/django_filter.html:5 +msgid "Submit" +msgstr "Potrdi" + +#: filters.py:336 +msgid "ascending" +msgstr "naraščujoče" + +#: filters.py:337 +msgid "descending" +msgstr "padajoče" + +#: pagination.py:193 +msgid "Invalid page." +msgstr "Neveljavna stran." + +#: pagination.py:427 +msgid "Invalid cursor" +msgstr "Neveljaven kazalec" + +#: relations.py:207 +msgid "Invalid pk \"{pk_value}\" - object does not exist." +msgstr "Neveljaven pk \"{pk_value}\" - objekt ne obstaja." + +#: relations.py:208 +msgid "Incorrect type. Expected pk value, received {data_type}." +msgstr "Neveljaven tip. Pričakovana vrednost pk, prejet {data_type}." + +#: relations.py:240 +msgid "Invalid hyperlink - No URL match." +msgstr "Neveljavna povezava - Ni URL." + +#: relations.py:241 +msgid "Invalid hyperlink - Incorrect URL match." +msgstr "Ni veljavna povezava - Napačen URL." + +#: relations.py:242 +msgid "Invalid hyperlink - Object does not exist." +msgstr "Ni veljavna povezava - Objekt ne obstaja." + +#: relations.py:243 +msgid "Incorrect type. Expected URL string, received {data_type}." +msgstr "Napačen tip. Pričakovan URL niz, prejet {data_type}." + +#: relations.py:401 +msgid "Object with {slug_name}={value} does not exist." +msgstr "Objekt z {slug_name}={value} ne obstaja." + +#: relations.py:402 +msgid "Invalid value." +msgstr "Neveljavna vrednost." + +#: serializers.py:326 +msgid "Invalid data. Expected a dictionary, but got {datatype}." +msgstr "Napačni podatki. Pričakovan slovar, prejet {datatype}." + +#: templates/rest_framework/admin.html:116 +#: templates/rest_framework/base.html:128 +msgid "Filters" +msgstr "Filtri" + +#: templates/rest_framework/filters/django_filter.html:2 +#: templates/rest_framework/filters/django_filter_crispyforms.html:4 +msgid "Field filters" +msgstr "Filter polj" + +#: templates/rest_framework/filters/ordering.html:3 +msgid "Ordering" +msgstr "Razvrščanje" + +#: templates/rest_framework/filters/search.html:2 +msgid "Search" +msgstr "Iskanje" + +#: templates/rest_framework/horizontal/radio.html:2 +#: templates/rest_framework/inline/radio.html:2 +#: templates/rest_framework/vertical/radio.html:2 +msgid "None" +msgstr "None" + +#: templates/rest_framework/horizontal/select_multiple.html:2 +#: templates/rest_framework/inline/select_multiple.html:2 +#: templates/rest_framework/vertical/select_multiple.html:2 +msgid "No items to select." +msgstr "Ni elementov za izbiro." + +#: validators.py:43 +msgid "This field must be unique." +msgstr "To polje mora biti unikatno." + +#: validators.py:97 +msgid "The fields {field_names} must make a unique set." +msgstr "Polja {field_names} morajo skupaj sestavljati unikaten niz." + +#: validators.py:245 +msgid "This field must be unique for the \"{date_field}\" date." +msgstr "Polje mora biti unikatno za \"{date_field}\" dan." + +#: validators.py:260 +msgid "This field must be unique for the \"{date_field}\" month." +msgstr "Polje mora biti unikatno za \"{date_field} mesec.\"" + +#: validators.py:273 +msgid "This field must be unique for the \"{date_field}\" year." +msgstr "Polje mora biti unikatno za \"{date_field}\" leto." + +#: versioning.py:42 +msgid "Invalid version in \"Accept\" header." +msgstr "Neveljavna verzija v \"Accept\" zaglavju." + +#: versioning.py:73 +msgid "Invalid version in URL path." +msgstr "Neveljavna različca v poti URL." + +#: versioning.py:115 +msgid "Invalid version in URL path. Does not match any version namespace." +msgstr "Neveljavna različica v poti URL. Se ne ujema z nobeno različico imenskega prostora." + +#: versioning.py:147 +msgid "Invalid version in hostname." +msgstr "Neveljavna različica v imenu gostitelja." + +#: versioning.py:169 +msgid "Invalid version in query parameter." +msgstr "Neveljavna verzija v poizvedbenem parametru." + +#: views.py:88 +msgid "Permission denied." +msgstr "Dovoljenje zavrnjeno." diff --git a/rest_framework/locale/sv/LC_MESSAGES/django.po b/rest_framework/locale/sv/LC_MESSAGES/django.po index 82dde0d87..00acf5644 100644 --- a/rest_framework/locale/sv/LC_MESSAGES/django.po +++ b/rest_framework/locale/sv/LC_MESSAGES/django.po @@ -10,8 +10,8 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Joakim Soderlund\n" "Language-Team: Swedish (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/sv/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -316,11 +316,11 @@ msgstr "Skicka" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "stigande" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "fallande" #: pagination.py:193 msgid "Invalid page." @@ -426,7 +426,7 @@ msgstr "Ogiltig version i URL-resursen." #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "Ogiltig version i URL-resursen. Matchar inget versions-namespace." #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/tr/LC_MESSAGES/django.po b/rest_framework/locale/tr/LC_MESSAGES/django.po index 17e6e4a73..d327ab9e2 100644 --- a/rest_framework/locale/tr/LC_MESSAGES/django.po +++ b/rest_framework/locale/tr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ # Dogukan Tufekci , 2015 # Emrah BİLBAY , 2015 # Ertaç Paprat , 2015 -# Yusuf (Josè) Luis , 2016 +# José Luis , 2016 # Mesut Can Gürle , 2015 # Murat Çorlu , 2015 # Recep KIRMIZI , 2015 @@ -16,7 +16,7 @@ msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Turkish (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/tr/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/tr_TR/LC_MESSAGES/django.po b/rest_framework/locale/tr_TR/LC_MESSAGES/django.po index 171826a63..94856c70f 100644 --- a/rest_framework/locale/tr_TR/LC_MESSAGES/django.po +++ b/rest_framework/locale/tr_TR/LC_MESSAGES/django.po @@ -3,13 +3,13 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: -# Yusuf (Josè) Luis , 2015-2016 +# José Luis , 2015-2016 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" "Last-Translator: Thomas Christie \n" "Language-Team: Turkish (Turkey) (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/tr_TR/)\n" "MIME-Version: 1.0\n" diff --git a/rest_framework/locale/uk/LC_MESSAGES/django.po b/rest_framework/locale/uk/LC_MESSAGES/django.po index 51909058f..2bd4369f8 100644 --- a/rest_framework/locale/uk/LC_MESSAGES/django.po +++ b/rest_framework/locale/uk/LC_MESSAGES/django.po @@ -3,16 +3,17 @@ # This file is distributed under the same license as the PACKAGE package. # # Translators: -# Denis Podlesniy , 2016 +# Денис Подлесный , 2016 # Illarion , 2016 # Kirill Tarasenko, 2016 +# Victor Mireyev , 2017 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Victor Mireyev \n" "Language-Team: Ukrainian (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/uk/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -317,11 +318,11 @@ msgstr "Відправити" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "в порядку зростання" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "у порядку зменшення" #: pagination.py:193 msgid "Invalid page." diff --git a/rest_framework/locale/zh_CN/LC_MESSAGES/django.po b/rest_framework/locale/zh_CN/LC_MESSAGES/django.po index c21604b42..345bcfac8 100644 --- a/rest_framework/locale/zh_CN/LC_MESSAGES/django.po +++ b/rest_framework/locale/zh_CN/LC_MESSAGES/django.po @@ -4,15 +4,15 @@ # # Translators: # hunter007 , 2015 -# Lele Long , 2015 +# Lele Long , 2015,2017 # Ming Chen , 2015-2016 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: Lele Long \n" "Language-Team: Chinese (China) (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -63,7 +63,7 @@ msgstr "认证令牌" #: authtoken/models.py:15 msgid "Key" -msgstr "" +msgstr "键" #: authtoken/models.py:18 msgid "User" @@ -71,7 +71,7 @@ msgstr "用户" #: authtoken/models.py:20 msgid "Created" -msgstr "" +msgstr "已创建" #: authtoken/models.py:29 msgid "Token" @@ -317,15 +317,15 @@ msgstr "保存" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "升序" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "降序" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "无效页。" #: pagination.py:427 msgid "Invalid cursor" @@ -427,7 +427,7 @@ msgstr "URL路径包含无效版本。" #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "URL路径中存在无效版本。版本空间中无法匹配上。" #: versioning.py:147 msgid "Invalid version in hostname." diff --git a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po index 9f5cd24f1..aa56ccc45 100644 --- a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po +++ b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.po @@ -6,13 +6,14 @@ # cokky , 2015 # hunter007 , 2015 # nypisces , 2015 +# ppppfly , 2017 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2016-07-12 15:14+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-08-03 14:58+0000\n" +"Last-Translator: ppppfly \n" "Language-Team: Chinese Simplified (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/zh-Hans/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -59,35 +60,35 @@ msgstr "认证令牌无效。" #: authtoken/apps.py:7 msgid "Auth Token" -msgstr "" +msgstr "认证令牌" #: authtoken/models.py:15 msgid "Key" -msgstr "" +msgstr "键" #: authtoken/models.py:18 msgid "User" -msgstr "" +msgstr "用户" #: authtoken/models.py:20 msgid "Created" -msgstr "" +msgstr "已创建" #: authtoken/models.py:29 msgid "Token" -msgstr "" +msgstr "令牌" #: authtoken/models.py:30 msgid "Tokens" -msgstr "" +msgstr "令牌" #: authtoken/serializers.py:8 msgid "Username" -msgstr "" +msgstr "用户名" #: authtoken/serializers.py:9 msgid "Password" -msgstr "" +msgstr "密码" #: authtoken/serializers.py:20 msgid "User account is disabled." @@ -317,15 +318,15 @@ msgstr "提交" #: filters.py:336 msgid "ascending" -msgstr "" +msgstr "正排序" #: filters.py:337 msgid "descending" -msgstr "" +msgstr "倒排序" #: pagination.py:193 msgid "Invalid page." -msgstr "" +msgstr "无效页面。" #: pagination.py:427 msgid "Invalid cursor" @@ -427,7 +428,7 @@ msgstr "URL路径包含无效版本。" #: versioning.py:115 msgid "Invalid version in URL path. Does not match any version namespace." -msgstr "" +msgstr "在URL路径中发现无效的版本。无法匹配任何的版本命名空间。" #: versioning.py:147 msgid "Invalid version in hostname." From d875fb3272fbcb71bb153ca421881907bb1d0bfa Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 21 Aug 2017 12:05:25 +0200 Subject: [PATCH 043/217] Update compiled translations. --- .../locale/ar/LC_MESSAGES/django.mo | Bin 5476 -> 5766 bytes .../locale/ca/LC_MESSAGES/django.mo | Bin 9646 -> 9646 bytes .../locale/cs/LC_MESSAGES/django.mo | Bin 9031 -> 9031 bytes .../locale/da/LC_MESSAGES/django.mo | Bin 9881 -> 10401 bytes .../locale/de/LC_MESSAGES/django.mo | Bin 10609 -> 10926 bytes .../locale/el/LC_MESSAGES/django.mo | Bin 13507 -> 13507 bytes .../locale/es/LC_MESSAGES/django.mo | Bin 10779 -> 11064 bytes .../locale/et/LC_MESSAGES/django.mo | Bin 8732 -> 8732 bytes .../locale/fi/LC_MESSAGES/django.mo | Bin 9993 -> 10549 bytes .../locale/fr/LC_MESSAGES/django.mo | Bin 10770 -> 11014 bytes .../locale/hu/LC_MESSAGES/django.mo | Bin 9123 -> 9123 bytes .../locale/it/LC_MESSAGES/django.mo | Bin 10359 -> 10359 bytes .../locale/ja/LC_MESSAGES/django.mo | Bin 11941 -> 12295 bytes .../locale/ko_KR/LC_MESSAGES/django.mo | Bin 10022 -> 11720 bytes .../locale/lv/LC_MESSAGES/django.mo | Bin 0 -> 10841 bytes .../locale/mk/LC_MESSAGES/django.mo | Bin 10623 -> 12660 bytes .../locale/nb/LC_MESSAGES/django.mo | Bin 9803 -> 9803 bytes .../locale/nl/LC_MESSAGES/django.mo | Bin 10373 -> 10608 bytes .../locale/pl/LC_MESSAGES/django.mo | Bin 10801 -> 11121 bytes .../locale/pt_BR/LC_MESSAGES/django.mo | Bin 10238 -> 10238 bytes .../locale/ro/LC_MESSAGES/django.mo | Bin 10895 -> 10895 bytes .../locale/ru/LC_MESSAGES/django.mo | Bin 13430 -> 13441 bytes .../locale/sk/LC_MESSAGES/django.mo | Bin 9411 -> 9411 bytes .../locale/sl/LC_MESSAGES/django.mo | Bin 0 -> 10390 bytes .../locale/sv/LC_MESSAGES/django.mo | Bin 10426 -> 10625 bytes .../locale/tr/LC_MESSAGES/django.mo | Bin 10550 -> 10550 bytes .../locale/tr_TR/LC_MESSAGES/django.mo | Bin 10522 -> 10522 bytes .../locale/uk/LC_MESSAGES/django.mo | Bin 13352 -> 13478 bytes .../locale/zh_CN/LC_MESSAGES/django.mo | Bin 10007 -> 10342 bytes .../locale/zh_Hans/LC_MESSAGES/django.mo | Bin 9796 -> 10362 bytes 30 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 rest_framework/locale/lv/LC_MESSAGES/django.mo create mode 100644 rest_framework/locale/sl/LC_MESSAGES/django.mo diff --git a/rest_framework/locale/ar/LC_MESSAGES/django.mo b/rest_framework/locale/ar/LC_MESS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V?*Z21JKTwz z?)_ZKrRR0vH1^;N&Sim3mu3{nexI+!(-h+>h-vTsilTOT8uVum<*BXdjZLMG8KY+H4!cOFSJ^PcB|5|p3E800aQg4 zY$_9K1qIBMRtGjr21&&Mhs<>!*DQD3#hEgP$UUT9iyBfDQ0SEM8fQZ9JnhefTC$g{ zPe1m0y!O+)O8ZmZbUNm%^4RnFsWV4|q4r?7#R?zk47W9gi2Q*_A{iVSkBlX*MUwIH zPHSj19*ZQb-qG=BA{iaAP9)>8Zt|*oBRx_O$+1^TVs>#^xjpD#wyOgj*^8@p?0Dd3 J`gZBM=Pz{ueBA&5 diff --git a/rest_framework/locale/ca/LC_MESSAGES/django.mo b/rest_framework/locale/ca/LC_MESSAGES/django.mo index 7418c1ed05769800a93e799c05042bf4a73c7c7e..28faf17fffec2592a0bd0b1c29165312edb30459 100644 GIT binary patch delta 26 hcmZ4Iz0P|>peV1ou7QQFfw6+2iIu6v<~Y#+0RU`@2P6Oh delta 26 hcmZ4Iz0P|>peV1Iu7SC(p^<{2sg@-tR@hQL@^TejeQVI@DhSACd8n`2aJRes3dBPB${Bne1Egkn0Uf}Kj+MLXU_Sb z{~1mVyt6s+Lt)mNhGr9sh@MPij^RW$AGFtVjH$pAXkiMM;J5fFKEMUI@S*hYS7I6C zA*{u5T#l#Ek6&UpUd8psB+R^Aw_`@|DZV&^oj8r#v1Yb0&6vQ|_%Zh3eQd*yIqC18 z!+yr+u?qjeLafS5Ppk=beXHkTT+Q>%X*!L3@g4HdF3m8JsJKjazaPd52N^uox zJcwG!9@Lh-fJ*7x-uRaH{ok0$^-9v9OjPrsEo(*HZv+!d={R&s@HAR@9_QmXn1$2G zZkV6&3H$@ucC(Z}lJ&?X(~7!JKdO92@nJmZjgMkI<723;{$xJ+*9tO<(tlWv8aJbg zXc(Jt5>*4|yzx!c3QCI8f42fH#sjDcM$pX&&SHEEHKA!-hQHtnEG;4bJLvQ?ZLRcu zT!t!Xti>JP_+`|@KST?!B2l3s>-v-;>=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?>K|{TgSjhH z6APh=Xb-N(w=s-g;cg5RnytpieV_4t4I8-r9)2D$yNde#>0yx?0MA0-$8cOzQ+Ol1NDGzhxFmg$lUC8e|!$t z>Q!@rj=s2oEY{M?Q!k7%WOr>4RsH*sx!NnJ<28qrhh0SGW{b!HuypdLch^efWLpU; z*VV`?#&)76^aPga{7=%+DL9Inz;RUdpFtJPdDIU5jHJ_An2n4ei?pYFUqw~*JZg)t zV-uFLOf4{i%+U@bS+`@@%=2xYj&gk+^}sN1pKjcT2XPLy@>~)wgQyh`U_CyG0ld>x zplVvBQliQ95!(oEm3#)+2$9g1DUWK(yILBtli;`}w{R0`#X2EsY(%oknQyX1e7B%d z!V5CFGydfyb$qIRbZT^B)F@D`Kh-i}E1{iG+f8&5V?+kQZYEc&;$p$c9pbdwL&V)} zBLn5Rhfq4yv|CC=FQFY&Qw{z9eC7M@roy|^9;4Gm>>yM~YN`k2P)(;~1EF)Rlc1KB zB6)H~=|AF+b9^86t<{Wpd09H4;%g)Ni9A9@qqc;2l-Nw{BGep0?*kQ7$UC~UE#Q5b z9n19kR!juk-}CCdb@|HzUVFh@ntQ8o!980Pa(^rua(5Ib`kRBHmSDKS2{*Ne8`p6zGmXX8wKvXj{BU#Q<3pY*aom8pdhvKov)ffO{2w^~+7bW& diff --git a/rest_framework/locale/de/LC_MESSAGES/django.mo b/rest_framework/locale/de/LC_MESSAGES/django.mo index 317124886528d1de71f4021441d60acd700235dc..eb0ddf66dd4a54ffac32403317a4b4db1bd2dacc 100644 GIT binary patch delta 2630 zcmYM#TWl0n9LMpqEwrUbxlafgh;?(c=W+l48#WoZ!d%dH4+m+j1OLr1Y@EhB>MgBPW6QUe$E+Y&Ybf<=S=Un zy}LPmYt*1qhSEz+BEtE`9Kq)b_@SIDGG;2ijTTvQL;61$Gtf5kkTTmUmifiygT!EpHxeixh8SV8! zJBFIcKGe+KLQ-lj1?`8y|4(50`CMOt%0vS{TDo>jt3!{Ldpb{lFl zC2$cQMXm9bp#1agK0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l5_qn*$6X3qxwuNZBBxQh6#z$}Z?g?!K^i_NNV3S)Q%6ZkJyVD)0NGVDP8egLn; zhp-MEti{i96aJ1{up!`@wTC&_%7xFc9g8nB>%%U*9*UMosks2TQq7#|M+LX4DKjQ5|J)BfgDo_#Jj)d5Kv) z4k3Sbh!5R&1Z!{>wQ{~vvo#pUB=%xGX0cmK{XPdb;9tmZY{N3MC~iib529u;ikgw* zIpJNOLCyFaDkc8q`QOKJHRr7u#yc>Ek7Ed5$E=@&4>@3U?HFE*$B{JIAE*cagL*&- zCqlcei2n0VS3+y>q4x*a+vWhyos9mEb7Md7{k&l z@&ikvif9nm;#=5&U*SIVtuR}Ow|G9_`6904`cXXTGy4{mqIV*!zjFO0!_*SbV+_kE zY3{Kmtim0r0o{ky_&jO`6Sxb1!G3I}_ilU{(|8tDD{*Gkhj(HMKSlliV%Ga2$78#z-$E- z)55_Z_TXVub46A4x@aj`@2vBx(8Kk4)Q9n_s}hByqfdl z-uWDAK=Y{jvqGNg=fX;4wXFiRWGPgRIJ)Kmv* zT4ojTMq)Fet;r+ZodC9*$Z9FnshSE1%!XoskgCe1(JieL-T>z(hzc4C0=6IuZkrizpayH%`w?;sX76*K=z z+-;}ysVQxZM4C{osc9wu?_c>|*vb~1?B!T_y^&b!T~}qZbKRy_w9=(qEAMK>dEA|$ zeXkv%rh-&cTGg)6hE8 z_U7gSnWEg_vb%jwX|O)m5nSTS?FqeG-~__c&KKdNvnaCN8IEL~=}5rem}*$>oQp&f zyAOh diff --git a/rest_framework/locale/fr/LC_MESSAGES/django.mo b/rest_framework/locale/fr/LC_MESSAGES/django.mo index 2bc60c63a1e7c38332b1c06124ebff5b552c2e06..e3ba4a2c5065d049f697094a8cece8e499b8db56 100644 GIT binary patch delta 2367 zcmYM!e@s&np=)PdVkJ2y%pU|>=_uoBnZ|ASIo4zLbYnWP2{+(*ti>O&4QI|UrUtuE zzn{Y>-o$0Npum_pxCJ%9J*a-yH)G6M0zL2wR^wmDpDCFcjC4I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n2xU_7a1JxS$8e%a1-165Dg-YONzY-^-$p{ghb&3-F=M0U~MO>LnrqAF=r zlq4Kq|DC-K**(9+x$5Zj@2uQHsv{LU+TN8Vujd$xjc(X6lF0Xu&1aoY7aF^Rm@cgr#($w zr4B{e-{rUdzckR~-Q&ksquo@6P+?GMqAFJ?<$g@mQZ_4*RFo*~RK;6m{p6e34LOqq zp{C4KB9csf5y=TGi`7O`cOnt5qknj)=YSXQ-@oU;$ex6^YGin*k=o}5CMyc-^Cr*E HUlIHdDaz3+ diff --git a/rest_framework/locale/hu/LC_MESSAGES/django.mo b/rest_framework/locale/hu/LC_MESSAGES/django.mo index cb27fb740a8f8efca1fd9c8264bb56df60d5b078..8b884fbed0e46c3ff25408f56c75c10a2fc7ffce 100644 GIT binary patch delta 26 icmZ4NzSw=kVj*60T>}eU17ih46Dw1T%^QS13jhFerwB&? delta 21 dcmZ4NzSw=kVxh^^LYyq7R)!{30su7QQFfw6+2iIu6v<_s}@Apm?$2bTZ< delta 26 hcmew!@I7Edv>30Mu7SC(p^<{2sg=2aW&$ diff --git a/rest_framework/locale/ja/LC_MESSAGES/django.mo b/rest_framework/locale/ja/LC_MESSAGES/django.mo index 1f934cc378a47eb5d4f15aec1e1bde9e58f6acf2..9ce42cfb36dd3d3b65145832e854667adfe857d3 100644 GIT binary patch delta 2580 zcmZA2drVe!9LMn=pxi|8ii)?Bnt2031rQ1b>H;SrwF=W#xiX068uR5XS& z(L$}I>*CDSKQI+*HfwWh>OWmJx3;n!Z~T*8)*m@HdweH0;JC{1r=$iJD$AWmHV#ZW+O)cnOO!zMnB`a1qYN6F3jQ!*WbdGo}#Nqkcbz z6?g;3V^)7-2H^r!2P;waA=jueN66@f=P@7uME=aAbg!ocs1YwfHB^st@B>_kH*paT z&oCwjHzHN04RzlMoP^(_X7UkE!7&49hxW}fGP$@G^@0Pq3@>02#trmdxDc}_ukg!3 z)JS%rM)n>urKZO(Kk|Pc!SEBPFG9^k2^TG06-M>K2$^T_5N6_ew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)`JKlf zhhlH-Ok67n95GUySV~l8n7xQi3-};y%raY!n=pb;;axa|cj9R*!Y@(3{{>4hm~EDW z5$50(z#XImPSI)T2pIHHF zM)l44sQ zOQ?2lU<5xw4e$r#P+9&GvrOzm4X7ViVGL_<3j6Ww64qZcEn@h^xXc+v&9v8*ci>ve z6L>z&>>bn=?dIs$#x!LGXRe@l?*r6SC~>K8Q2;DE^3#W8*UaFu&&f0{2s&!9nQ67f=ICTp-g#=6BRg zR+ak3Q60|W4xC4xX+05c0FIzKn8YDGfjcp4=kl#e3y3A;t6 zi;9+Vzu`gLO!+cuWlAc{#&Hav#P5)?S|@i>hiVAfPMdM%Q_gR&mio{Ne{0%MXW;;9 z;D@kY_y05*&Fp7v!A$Ok_N)`t!5-w#-sWQgUP2~iS5Wu+FIQj9CD#^4QT=tJH$c?y zW>5n^=E@&o7tgnIWM0AGJ^q7_pc-C4`nKyx6U$-Pk72EI%6S8|buAomwVy;i_&927 zFX15OR{C4F+xaXe)Zic)H8_VFNQCKUbfXthP)2EL!|?hN=)9{rgroO=f2Qk z>?U+emJ(V)9pqHX^D;btJDD6;y8-iEzS;SIbkzokO++2R&Un{Nt58TN>Hf3gwu{id zHxgQ{BI02pLh$CbM~E`be+3aIdI%jHr7gsIVj;nS_x?YmqxM&~qKn8Pv~5b-rW#@+ zkx3}6A-MMTgbE~f*S2~&|DfxPX%O~+s}$PjPNJ0H26?aBVoaqV8C|zj>Lb(U3K`fz zWG9bjeGp8>@}EviE-F}`IXxUsOn)5C4%9W&tec(>ha=lY#>aN;jdYCc8QnWEIvi=5 a7$0jRhFnE*ZP7?5d8VQvJsDd$oAoax!qzMR diff --git a/rest_framework/locale/ko_KR/LC_MESSAGES/django.mo b/rest_framework/locale/ko_KR/LC_MESSAGES/django.mo index 6410f0b1cd6cd733df113762a4664c01ecae63ff..f83b7ed71b63d3d110a39732d083b34041064211 100644 GIT binary patch delta 3028 zcmb8vdvH|M9l-Ik5kh$6K?slbTVLk6|H-gE9fkKf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/lv/LC_MESSAGES/django.mo b/rest_framework/locale/lv/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..2dc5956f3c07ccea0842db3d6cd6549f1f0e9dc3 GIT binary patch literal 10841 zcmb`MdyHJyUB_=;b+c`g5a=tAa*Kc#zJ5G57-b z$Kdnez3=h7E8r>cS@5giQSjT~dGMk4dfp`X5-8ul0?vTn0-ppQd!Oe$3LXQ6zfXbk zKFIM`K%w^8DDyPH=fK|pkAwdJo&rDgu;*35mqA{6Ujn7y zSHb<@--05?x4<6|MTE9_;qj!yypipddI=Xc%IFlEhy`_3d*{E z4HS94o!8f@yWl18>)^}a2*f@GHo*(v>!8@nK7@A; zJOe%p{xWzB{7dkPd}lJTuUEiNg1-&c!2bn53eIC3sKi?X#ZG>aACc$RK+)Sjg0tZJ zSe*FT%OI}i{SGMdeGPmH{1fmv_#N;B_)+C~3*ZuX8GHkj@sB*=d6=sAS@0Mbf-=wV zf#N6slHG-$4aF%wTT4aS+jX3*ZA_0*YMLL0QMo zf$stT02DcW1C%(i1qwfZ2kryE2g-bJg2KmR2vhX~9g^x!uTCt;Z zpxFHlP}co5Q0V^^D0=#DP~`G|IgTQPeLTMaJ_ud}?*Tteo1}@3L_WnOYmK_ zCb3{f9=N7yVmoq4>~q)Xh7G!Da&1)ESOsCCv|7==ZKzrp`bGy;Z_gg}R%q+y79F}e zX{kXk=%!}pL<oux6`N?qM9M@_7^$#cPou~*g)6opGoA`lzv14+^pBU;6rG<~!r&Oc1AtCTZzJSm#zdNvTely$;kyM_*lRn7Zv~f3fT9 zx{0r;{8?qsRqu}J*rrWnyhG%pk}%Q!ofBAXVX%wY@IINELAhQ@XN{3)El{`-j-q`8nJp)Cz&(cgCXRO-2SbB#h@c-JMq@v1j;eYX z#5PVWMvsyECJ`|mRGCL|lLq)nTt^GBaMW7s;)+g=Wn$BFE6>Ph@QBil2EBLmS-3PK zyqAZWj<$ZO|JANRO$~T#h(FfSL^WMZlSlC_2n_de4maFyxR0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+wTjb%t<<3~wuMp(EgdXHYRjWmC?d3VA~a40q&pKQ z60xb#lsM=L0*W!pjtnkHj2adaUl7^&MlmrlE=Wy=q$XYX{oQ*KPx`-~bIwffJ&*sn zGq?NXuH3Ci;BBK!5DyS-rDiiY5aL2PT4q*{$1sk0d>Aj|a{LKv@L$ybN6O9Wa1Gvz zJ8(6QU;e`Jbn8 zfc9Bjfq!EJD;N0#tVi{4_RN`$Q_&4y!*;xi{MkGgjWks0&$trxpf>ElEOz6En8LrX z1rt>~4ELkHH;Iqn1=LD@gUxsc7x8?nU2L`%n@~5{i`#J;H{o}v8&)kbyC0XM+8aHtIg=%r#*hm1UU1IF4czU%~*+BD-LxaSfhBw%cwv ze?b21HW%Heh)SOdZW6-?s@;rhF^SsZ@hJPRkzaIQyoPH3hDxFZT!%GF{kVUYF=Y5=qND87S9yjsor@1s(rLo*#@__eslnL*8T+O<#N zW3(^g7bRxD;wswja|E=v*PU}1ryb#DvK2M4VSEseA-ig`IVwtq^Qfiy8nx65*pFeR zxf^%lFkZktIFFCx0Mj4Bw@}IW2X4g%o;HThqn7$h)cuz5^u0KW+WK693WK$u@gXeY zYFtXD$X?V9kD?y%F>>PUE{3s$e~M!{wqrAH#6zg#c?P}H;XY5q83g^~xLN0aii)zh zfXe>wQ7aOv_rI7#txO8ra0)e`kFW#ppq8?!!E7aVpdN6*wX>+DKaI@IF1h|2SjzLQ zNQJ@KJZc~{Tv&bULM_n}~k7$d8ft>%l7nUp#Vr>PR}?HI>cu5EHJWWg?p?tg30KD4bjIS@1tZ C(9Nv? diff --git a/rest_framework/locale/pl/LC_MESSAGES/django.mo b/rest_framework/locale/pl/LC_MESSAGES/django.mo index 8af27437f01d85967413cde8c9ce0b58231f0f36..99840f55c0c90c1b3946d92ecedde7aaf2086cd4 100644 GIT binary patch delta 2495 zcmYM#TWnNC9LMpYKyPT37D@qufkLIi;%;eaDcx;pD~Qx`D@Cs5xIHaf+TGeMRG?vf zK_DcGYVB(XBiKdDvF~KW|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x zbrSWFm>ASSZlDf&2hZX-261UQ+l^;%J*r*VnyJBhp)yBk*m&>`_v1G_iY4hod8-Q= ztDLTCr@LIaD?RQChl`)dA4(*hE%8u)A{t7@;vUt~6YC2ll(#1yNhBlPsx}$xtLN%k z7)U=@_jrl%(NboNSp3+!Qf01XMrK~CnMswoYJ@Dx2v~i_KdaSvZasjVMyGAS$k^Jr X%xSN>mz(o4{k6E?l%vxAvdX;wT%wuh diff --git a/rest_framework/locale/sk/LC_MESSAGES/django.mo b/rest_framework/locale/sk/LC_MESSAGES/django.mo index dda693e32c59738c5bcd1218feb7157b3a5a6078..83d43c8222cc9a35707717997913dba52a1ad0e6 100644 GIT binary patch delta 26 hcmX@?dDwG%;%2Uq|A delta 26 hcmX@?dDwG%->2TuS1 diff --git a/rest_framework/locale/sl/LC_MESSAGES/django.mo b/rest_framework/locale/sl/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..9ac13843f70a0543b748fb73af9bbb41eba8e880 GIT binary patch literal 10390 zcmbuEdyHJyUB_<{H)&1!AV6qZlAdmw)+V0uuI<=n!zT4J*~DINy=#}4w&v{2*_k_Y z=icePcgEh`7!arxm1F)WDt}ZB#TDWY{y;)Pt%^h>zzYH?NDv`aNIZ&=C=wu1@mCcI zKHqciyu7=%ORo0J_dd?!cYg2l+kbpy*H;3rRoYL{&O8tVUjko!kRPt!es>Uj6ub!< z@Xx@fz<&jw0C&G92tEkz1vUOS_+juexEtI6E8rKwec&I04}sqWkAwdXo(A{PS(t$@ zfPVyj61@LMg5V-}0z3kK6?_)_TkvJ@eGdo0EO-gj_pg9wz&F7s!4JJR2p$2S14ZAb zK)sJk{4%Kdz6m}9ejns7*z>-E&cmSg`y8ls>fllE>)`X?cfb?i2j3qARq!()uY&8K z`h6AL1HJ`{k8guN4LO2j%kvY~}#ZkAtXgun3ATm%#7c7X%Ize;1hKaj*kUf!9IN`}-iI z1b+#B4E!hXBj7GRq8h=+z`fuh@DTVpQ0x2#_!9U!c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~6bCI-*-i?#OWpzG$r; z3s3N8a-7*i!h`%3BE~Bc7uiXyDuyT86Cf6&+=jCvN+bjFb(O-(;MLX@FF(CccjkL|dwKOo@VnMvjE&CEBeYehSA*zYVd=)}Hd>KNTF4k^Y zlY_uEZwY+uoZ_EMb}$sv#vl+7o*hPGZ8)sDO(pe~^P?ZeG*?tNg^V+#~pRB;`7J+AM9%88ewJ>;tCTw5H*kK0x7qOD4 zPzE{zmMAGaWAy$I^GpbQB)nnAD6mB>oU zsz^%C^>Wne-MSH+YZqAz3ZNX!5qc?%U@y3+QDKA_nDiA%V;fvlyl+#9*eL5FLucu0 zBa@MK>UL@H4>D>Dn9LAm-Hkf zW3qjEp0?nV(Jss6%MU5`fyyJNEmab@cF+BlPr6!l z>fT38>3=HY)Q+;N0aYq=`M`bqE*+#Td(BEIB9vbh{1DBMZzGT5Oo#v9XEc$s5Qi+hla!?+bs2O?|iIJIY0Gc-xsD82Qt_{>1wROx?cmD@vwL-4| literal 0 HcmV?d00001 diff --git a/rest_framework/locale/sv/LC_MESSAGES/django.mo b/rest_framework/locale/sv/LC_MESSAGES/django.mo index cbecec44db41c28528e50379a8db597b0f7bb909..232b5bceeef9fb4c7b8088db98509889225297e0 100644 GIT binary patch delta 2317 zcmYM#TWl0n9LMp0TY5#%wn!3rKQE*Y;C)=2owrJTMD!wjNR!aw!6B!7>LAG zi5Da>v6TlKiAdl{jSn>#i9V=EVoZ%uNsKX#C@&`J1Mx*{jNjkv5Ki{Y=bYKung2Qe zb7n8^dA>I}SFqrWQHH52sNET6r|?7;2gk=!TcD9&aKaTemnBX#;A+ZKwx@u?gSCcKi`L zaoOEw)p!s&Wv5ZsP2)QJ9yOEm_yCsO!*h7PbW1yOoc^w$ zKZY8~G1SQ3LZ;L{4*K)K_r(l9gY&JZnb^cZsq4d}ZWyPr7GJ}qcnKYx#X|fG7hpOa zvSQh|0Sl02U>$)wkV~x(b)ON`GI|z^@Wr5i7B%1th2&qkzQzfSpma&4g=bhJDxjXgBr0|9VF>?5cBIv>Oa;0L`PeoN8o($v;(65e{0RrO z|JORH8=ORThF!rn`~j7tLiUWdPdirNC~A97qNey9hVWb5g8AjFaNLhlg+Hc#!%>P$XNOY56E_+>xG?No)M zN!COv2}+#iLWLD;kNBTd0py>!^FF+EdC!4^_!k(e@eeTXzm2n!LRHJnO9TmPJ*b zR63|yY?L+r-b*VPRWUDqG#2+F o)y_^u;Km#t;U#WI5wE%v#{1=qvI^pfu@N^C_H5W4ANL#o1K|VzUjP6A delta 2137 zcmYM#e@sArA>IS>;9-PE>{1$b?qUC0{;!4!G z74;_DP)q-WbIP5c!6lqOk6M9wRLU-+?xT~LTCAW`iYfGP5KHhm%*AOW3-$)a@g$ON z`^Nbr@@JPh=ss6b#zx%Q7IlSA^)2BX?Ni{)OZ0^L^p69mfaHMb|-2) ziF$)CP}lv09xkFLSh~V5F6+h+<0;exrtvO3fz3F#g7x1`=PD=kraPE^Ii{WCs5hN- z1|o0U)3U05;!7yc(=ontNF(Y9(4w6G@{!e;#$C*WLINRB@d{ZO4nKef_oI4^1ivqSYvFi5(Gv`9+wAeY&ivV;XjdpZ8p~wQ z#`1I5wlycR|HNXe`}a?b4;}JS`=1^=ba-sk+jw|lJV}hW6OAJi;~leQWt9c9&#bx@ F`VYHh&N~1A diff --git a/rest_framework/locale/tr/LC_MESSAGES/django.mo b/rest_framework/locale/tr/LC_MESSAGES/django.mo index 818aad27929ca67ead8eca3a42804446d8192935..586b494c3235f43b2b20e6ebf1f094336286b3ef 100644 GIT binary patch delta 26 hcmdlMv@K{uj5x2ku7QQFfw6+2iIu6v=1lRkf&g)*2igDt delta 26 hcmdlMv@K{uj5x2Eu7SC(p^<{2sg^J9<-7m%5hfrn+cS_sPs)7M;yZtBdSTTUA}V ztEBM(iA0LJ#1dtfMm20AE??dWUnI;22@(n-vVZjR#*pMCvA#^8Q5uoE-zK90fb&s1q&2LTtrZcnjxZzeM_A z8PX&>Q2Xt{FY!;*lYD_+VZvbMVSbrL;KUN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`dKcPlcv@&ob z>U=+H#1p8g@lf}l!y0@KSK~LB#Ovs-qOyj&B3O@P+Zu5bwjtAKlg>wxKl3=~K{Kdj z@&+dGE!X}S8)z@0rqp~65ffcnJ}$^!>A6t zg1YcCY{iv4RSx4l_$(^bUpr&u`Ci(cScfkmeX<4ABK#KXF|sbuYox+Hv^4I**O2vS ze<3^4qI6p~#;_k7Q7J!(TK)5=`*SLST{M6iv4^_uIn*v#bY4g8s>&qO!)4Y-rG*pI z*oN=mUHB(5P1eKPd50ZDJ@|3dR6Om@&pDUyR?h#1tUD{YC3sN{l3W``W$Fl$EIaG# zv52VXh9wN+cc>R#L3(J{Fp9NIylg;aXe%nUeeQf3)!`$qeF|@<{S@}#yQu5`aVF?( z8Sl3SDon2pU=u#%oJFmHCDe^!@}^9zMU9{p`N>9c2Tr3pc)|H0YLPCWcGWc;!MgRq zbx)wD2R}oFtl6umIlqW{@Tbn-F+@8;3={0m|BBWGo5L^u*N>VOrlwR2P-PpDBz60gTE(pkWBllzYFt-LxhUvPph|=$R$)#1l!r}Q-h)}-afy^zgb-8 z>Vr$&sVSCJ#>~yN(_opE@x_Z+5gQl>0As3Cs}y diff --git a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo index 396aded071dcd23c423b058c51168a736bea1410..a784846b2d7c96703a6999d8c77f9186efd9aa49 100644 GIT binary patch delta 2679 zcmYM#dr*{B7{~FmpxnG6f}v@y8mKAWQ9?xl^TtL>sEL+svLdOw49jF{x>#!91uq+8 zW8QNdol+auMDbQy{Zme+U8A8aCVCOBSYzt(wKxux0}00T#e?X?tC)c;_!uT78k3HLP}djWqqq>0a5ZM( zMjV2tF&=-!0%HQEjmi`{hH$p@<5XW>@h$0zWyWS+zG&2%cmaW3ixbvPZHZ~{8IMsGL~d(tkp+m)!9 zyo#FH9%M<)IlFz|{=Em&kEMSCY9;bHD0QV6&<*`m24Dkr$1~`}YuF8c!*&=$gRGc% z9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m zV{JLB?OAgxlS-TRPisA`a^B@)uC=z-a!ct4ZMkM^>&MJLEb5QmpL-u&opJ8#oQLOm z&N<)nJ?&F0~u5HIE{O`Z~c4KIvStIU8{r_d` z!Als$(nV%LOrRz-h`K)Ec^vh=^Vp!J-lVaZ3)TFvC~HEkFo7Bg{QCsZ~4s~BOt5fogdY(s1P=P}f=I*+~RUrE$(7jm#{1ohk@+=j3Ow%)3*CG&HD+j*^O>+D}#Z6+-Q&La&5VAt1Jcs!6Eq%98myhG_GFG}7RI zB}PvlBW=ZY?>~I8wf<~T$UCXZUX^{+R;o@xE|q9zKAYXhf-_0Usm&xA+%8*aDdQ7V zePmRWSK69(D*2u%O6J?+>udMlqHy0TduX&#b*}Z%QR$&-&sFq^-ayrs=>(`KpH!Nt zgVg)fp)AN^eV*$yqh-__s*++eRp)alm7|;~^Y|U0Do6Hau4KQ8`XnnK;?Aq{uR6~K z_P9R>l6mfM;i%6k2-di5!G%6|Aaus>1d7tmXGL)*C%nTs5KcMia3Hs#v9{j19u7x# z9~>VWnTR9~K9Za`k~|REa%6n0mHMD}!Ch4x@H_P-9eLM|zj^J%l=Ef9W_P+|GSBT@ g{gls%MmycHXo=5#zHHL(6jy%a%vLryE7o@X3l4nR*8l(j From 1a7ed296395a941c4db0d8ef02855ca079e7ff0b Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 21 Aug 2017 12:06:14 +0200 Subject: [PATCH 044/217] Update version number --- rest_framework/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py index c0b5c4c04..9da9989e9 100644 --- a/rest_framework/__init__.py +++ b/rest_framework/__init__.py @@ -8,7 +8,7 @@ ______ _____ _____ _____ __ """ __title__ = 'Django REST framework' -__version__ = '3.6.3' +__version__ = '3.6.4' __author__ = 'Tom Christie' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2011-2017 Tom Christie' From e389336ad7538b1216e40e57d8c92d178334e2a9 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 21 Aug 2017 14:47:43 +0200 Subject: [PATCH 045/217] docs/link.html: fix/remove undefined template var "schema" --- rest_framework/templates/rest_framework/docs/link.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/templates/rest_framework/docs/link.html b/rest_framework/templates/rest_framework/docs/link.html index f18d64825..fc2320a5f 100644 --- a/rest_framework/templates/rest_framework/docs/link.html +++ b/rest_framework/templates/rest_framework/docs/link.html @@ -99,4 +99,4 @@ -{% include "rest_framework/docs/interact.html" with link=link schema=schema %} +{% include "rest_framework/docs/interact.html" with link=link %} From 0a0bb6a871441bf0db00598eba64222f5bc6d073 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 21 Aug 2017 20:33:51 +0200 Subject: [PATCH 046/217] Update release notes For the last minute #5346 --- docs/topics/release-notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index f4a83324c..78dd334ee 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -67,6 +67,7 @@ You can determine your currently installed version using `pip freeze`: * Revert "Cached the field's root and context property" [#5313][gh5313] * Fix introspection of list field in schema. [#5326][gh5326] * Fix interactive docs for multiple nested and extra methods. [#5334][gh5334] +* Fix/remove undefined template var "schema" [#5346][gh5346] ### 3.6.3 @@ -1391,6 +1392,7 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh5117]: https://github.com/encode/django-rest-framework/issues/5117 +[gh5346]: https://github.com/encode/django-rest-framework/issues/5346 [gh5334]: https://github.com/encode/django-rest-framework/issues/5334 [gh5326]: https://github.com/encode/django-rest-framework/issues/5326 [gh5313]: https://github.com/encode/django-rest-framework/issues/5313 From 5fd01d06ab375c10f8821863617277fddd2a422c Mon Sep 17 00:00:00 2001 From: Felipe Bidu Date: Tue, 22 Aug 2017 11:00:19 -0300 Subject: [PATCH 047/217] Adding a more explicit error message when a view does have a get_queryset method but it returned nothing --- rest_framework/permissions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index f24775278..484630ae7 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -122,6 +122,9 @@ class DjangoModelPermissions(BasePermission): if hasattr(view, 'get_queryset'): queryset = view.get_queryset() + assert queryset is not None, ( + 'The `.get_queryset()` method from the view did not return anything.' + ) else: queryset = getattr(view, 'queryset', None) From 6f2c3bcb1287db58a191ab7ee4d9723a3377e716 Mon Sep 17 00:00:00 2001 From: Felipe Bidu Date: Tue, 22 Aug 2017 12:13:22 -0300 Subject: [PATCH 048/217] Further clarifying the message when get_queryset returns None to include the class name that was called --- rest_framework/permissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 484630ae7..01b74e877 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -123,7 +123,7 @@ class DjangoModelPermissions(BasePermission): if hasattr(view, 'get_queryset'): queryset = view.get_queryset() assert queryset is not None, ( - 'The `.get_queryset()` method from the view did not return anything.' + 'Return of {}.get_queryset() was None'.format(view.__class__.__name__) ) else: queryset = getattr(view, 'queryset', None) From 9b829bec2d0bb687c356b4c57091d175e9282fcd Mon Sep 17 00:00:00 2001 From: qwhex Date: Tue, 22 Aug 2017 20:37:31 +0200 Subject: [PATCH 049/217] Update 2-requests-and-responses.md: consistency Made it consistent with Part I. Catched it when commiting the code into my local tutorial repo. --- docs/tutorial/2-requests-and-responses.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index 5c020a1f7..bba52d82e 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -47,7 +47,7 @@ We don't need our `JSONResponse` class in `views.py` anymore, so go ahead and de @api_view(['GET', 'POST']) def snippet_list(request): """ - List all snippets, or create a new snippet. + List all code snippets, or create a new snippet. """ if request.method == 'GET': snippets = Snippet.objects.all() @@ -68,7 +68,7 @@ Here is the view for an individual snippet, in the `views.py` module. @api_view(['GET', 'PUT', 'DELETE']) def snippet_detail(request, pk): """ - Retrieve, update or delete a snippet instance. + Retrieve, update or delete a code snippet. """ try: snippet = Snippet.objects.get(pk=pk) From 6a3b8cfa4c2622ce38c5e0b217fcc5acb624a701 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Tue, 22 Aug 2017 20:44:19 +0200 Subject: [PATCH 050/217] Adjust wording --- rest_framework/permissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 01b74e877..57de3a35c 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -123,7 +123,7 @@ class DjangoModelPermissions(BasePermission): if hasattr(view, 'get_queryset'): queryset = view.get_queryset() assert queryset is not None, ( - 'Return of {}.get_queryset() was None'.format(view.__class__.__name__) + '{}.get_queryset() returned None'.format(view.__class__.__name__) ) else: queryset = getattr(view, 'queryset', None) From eb88687e28a8c75fff1e875d3a1568cd51a35c99 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Tue, 22 Aug 2017 15:02:18 -0400 Subject: [PATCH 051/217] Test RequestFactory with empty body --- tests/test_testing.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_testing.py b/tests/test_testing.py index 4a68a1e1e..ba42da971 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -274,3 +274,12 @@ class TestAPIRequestFactory(TestCase): assert dict(request.GET) == {'demo': ['testé']} request = factory.get('/view/', {'demo': 'testé'}) assert dict(request.GET) == {'demo': ['testé']} + + def test_empty_request_content_type(self): + factory = APIRequestFactory() + request = factory.post( + '/post-view/', + data=None, + content_type='application/json', + ) + assert request.content_type == 'application/json' From 807b9c716ca2cf6131993828ba37d37cfa673b98 Mon Sep 17 00:00:00 2001 From: Scott Kelly Date: Wed, 23 Aug 2017 21:30:56 -0500 Subject: [PATCH 052/217] Fix doc Response data attribute description --- docs/api-guide/responses.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-guide/responses.md b/docs/api-guide/responses.md index 8ee14eefa..e9c2d41f1 100644 --- a/docs/api-guide/responses.md +++ b/docs/api-guide/responses.md @@ -42,7 +42,7 @@ Arguments: ## .data -The unrendered content of a `Request` object. +The unrendered, serialized data of the response. ## .status_code From 26d4977cd065e54cee54e77d8998d11af458a3b6 Mon Sep 17 00:00:00 2001 From: Ashish Patil Date: Thu, 24 Aug 2017 15:06:48 +0400 Subject: [PATCH 053/217] ~api-clients documentation: installation code fix --- docs/topics/api-clients.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/topics/api-clients.md b/docs/topics/api-clients.md index 73434416d..85c806428 100644 --- a/docs/topics/api-clients.md +++ b/docs/topics/api-clients.md @@ -419,7 +419,7 @@ The `SessionAuthentication` class allows session cookies to provide the user authentication. You'll want to provide a standard HTML login flow, to allow the user to login, and then instantiate a client using session authentication: - let auth = coreapi.auth.SessionAuthentication({ + let auth = new coreapi.auth.SessionAuthentication({ csrfCookieName: 'csrftoken', csrfHeaderName: 'X-CSRFToken' }) @@ -433,7 +433,7 @@ requests for unsafe HTTP methods. The `TokenAuthentication` class can be used to support REST framework's built-in `TokenAuthentication`, as well as OAuth and JWT schemes. - let auth = coreapi.auth.TokenAuthentication({ + let auth = new coreapi.auth.TokenAuthentication({ scheme: 'JWT' token: '' }) @@ -471,7 +471,7 @@ For example, using the "Django REST framework JWT" package The `BasicAuthentication` class can be used to support HTTP Basic Authentication. - let auth = coreapi.auth.BasicAuthentication({ + let auth = new coreapi.auth.BasicAuthentication({ username: '', password: '' }) From c0475d059d500f4ab8abf394305df7c65856eec1 Mon Sep 17 00:00:00 2001 From: Vadim Laletin Date: Tue, 29 Aug 2017 10:39:52 +0700 Subject: [PATCH 054/217] Update link to drf-writable-nested repository in third-party serializers --- docs/api-guide/serializers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index a3f7fdcc1..e95f2849b 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -1180,4 +1180,4 @@ The [drf-writable-nested][drf-writable-nested] package provides writable nested [drf-base64]: https://bitbucket.org/levit_scs/drf_base64 [drf-serializer-extensions]: https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions [djangorestframework-queryfields]: http://djangorestframework-queryfields.readthedocs.io/ -[drf-writable-nested]: http://github.com/Brogency/drf-writable-nested +[drf-writable-nested]: http://github.com/beda-software/drf-writable-nested From ff2fa7a8663bdcdf962d31277bc8e29d22a2943e Mon Sep 17 00:00:00 2001 From: Benedek Kiss Date: Tue, 29 Aug 2017 22:22:00 +0200 Subject: [PATCH 055/217] Fix excludes I definitely see files from `__pycache__` as well as `.pyc` files in the package. Fixed according to https://www.reddit.com/r/Python/comments/40s8qw/simplify_your_manifestin_commands and https://github.com/django/django/pull/5817 --- MANIFEST.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 66488aae6..15bfe4caa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,5 +2,5 @@ include README.md include LICENSE.md recursive-include rest_framework/static *.js *.css *.png *.eot *.svg *.ttf *.woff recursive-include rest_framework/templates *.html -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] +global-exclude __pycache__ +global-exclude *.py[co] From 94e5d05caa285180356fa36e946433b5c93745b1 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 30 Aug 2017 14:06:43 -0400 Subject: [PATCH 056/217] Add failing test for #5371 --- tests/test_serializer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 91430a193..3044d7c6b 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -411,6 +411,19 @@ class TestDefaultOutput: serializer = self.Serializer(instance) assert serializer.data == {'has_default': 'def', 'has_default_callable': 'ghi', 'no_default': 'abc'} + def test_default_for_source_source(self): + """ + 'default="something"' should be used when a traversed attribute is missing from input. + """ + class Serializer(serializers.Serializer): + traversed = serializers.CharField(default='x', source='traversed.attr') + + assert Serializer({}).data == {'traversed': 'x'} + assert Serializer({'traversed': {}}).data == {'traversed': 'x'} + assert Serializer({'traversed': None}).data == {'traversed': 'x'} + + assert Serializer({'traversed': {'attr': 'abc'}}).data == {'traversed': 'abc'} + class TestCacheSerializerData: def test_cache_serializer_data(self): From 79c1f2154adfbb13fa5d7e24e9624afa41652a6c Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 30 Aug 2017 16:52:16 -0400 Subject: [PATCH 057/217] Fix authorization few perms tests --- tests/test_permissions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 6fbf766a0..70fb38caa 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -201,11 +201,11 @@ class ModelPermissionsIntegrationTests(TestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) def test_calling_method_not_allowed(self): - request = factory.generic('METHOD_NOT_ALLOWED', '/') + request = factory.generic('METHOD_NOT_ALLOWED', '/', HTTP_AUTHORIZATION=self.permitted_credentials) response = root_view(request) self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) - request = factory.generic('METHOD_NOT_ALLOWED', '/1') + request = factory.generic('METHOD_NOT_ALLOWED', '/1', HTTP_AUTHORIZATION=self.permitted_credentials) response = instance_view(request, pk='1') self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) @@ -396,7 +396,7 @@ class ObjectPermissionsIntegrationTests(TestCase): self.assertListEqual(response.data, []) def test_cannot_method_not_allowed(self): - request = factory.generic('METHOD_NOT_ALLOWED', '/') + request = factory.generic('METHOD_NOT_ALLOWED', '/', HTTP_AUTHORIZATION=self.credentials['readonly']) response = object_permissions_list_view(request) self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) From 2ea368e80f16311f50b31563abb70571b95fff86 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 30 Aug 2017 16:53:08 -0400 Subject: [PATCH 058/217] Add failing test for #5367 --- tests/test_permissions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 70fb38caa..ed5c7af7a 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -209,6 +209,16 @@ class ModelPermissionsIntegrationTests(TestCase): response = instance_view(request, pk='1') self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) + def test_check_auth_before_queryset_call(self): + class View(RootView): + def get_queryset(_): + self.fail('should not reach due to auth check') + view = View.as_view() + + request = factory.get('/', HTTP_AUTHORIZATION='') + response = view(request) + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + class BasicPermModel(models.Model): text = models.CharField(max_length=100) From c8773671e7adfe8e9de162f3215470f0ed879f23 Mon Sep 17 00:00:00 2001 From: Denis Untevskiy Date: Fri, 25 Aug 2017 22:14:33 +0200 Subject: [PATCH 059/217] + Rejecting anonymous in DjangoModelPermissions *before* the .get_queryset call --- rest_framework/permissions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 57de3a35c..26728b2d6 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -120,6 +120,10 @@ class DjangoModelPermissions(BasePermission): if getattr(view, '_ignore_model_permissions', False): return True + if not request.user or ( + not is_authenticated(request.user) and self.authenticated_users_only): + return False + if hasattr(view, 'get_queryset'): queryset = view.get_queryset() assert queryset is not None, ( @@ -135,11 +139,7 @@ class DjangoModelPermissions(BasePermission): perms = self.get_required_permissions(request.method, queryset.model) - return ( - request.user and - (is_authenticated(request.user) or not self.authenticated_users_only) and - request.user.has_perms(perms) - ) + return request.user.has_perms(perms) class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions): From 07258ca032e062334310c112469d6432f6eeb818 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 30 Aug 2017 14:15:33 -0400 Subject: [PATCH 060/217] Remove None handling from fields.get_attribute() --- rest_framework/fields.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 242d0f978..5730ca571 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -93,9 +93,6 @@ def get_attribute(instance, attrs): Also accepts either attribute lookup on objects or dictionary lookups. """ for attr in attrs: - if instance is None: - # Break out early if we get `None` at any point in a nested lookup. - return None try: if isinstance(instance, collections.Mapping): instance = instance[attr] From 0ec915e6234bdc602e131f08e8cff46fcf3dc3ff Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 30 Aug 2017 21:36:05 -0400 Subject: [PATCH 061/217] Force content_type inclusion in APIRequestFactory --- rest_framework/request.py | 2 +- rest_framework/test.py | 9 +++++++++ tests/test_testing.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/rest_framework/request.py b/rest_framework/request.py index 6f4269fe5..4f413e03f 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -303,7 +303,7 @@ class Request(object): stream = None if stream is None or media_type is None: - if media_type and not is_form_media_type(media_type): + if media_type and is_form_media_type(media_type): empty_data = QueryDict('', encoding=self._request._encoding) else: empty_data = {} diff --git a/rest_framework/test.py b/rest_framework/test.py index 87255bca0..ebad19a4e 100644 --- a/rest_framework/test.py +++ b/rest_framework/test.py @@ -227,6 +227,15 @@ class APIRequestFactory(DjangoRequestFactory): data, content_type = self._encode_data(data, format, content_type) return self.generic('OPTIONS', path, data, content_type, **extra) + def generic(self, method, path, data='', + content_type='application/octet-stream', secure=False, **extra): + # Include the CONTENT_TYPE, regardless of whether or not data is empty. + if content_type is not None: + extra['CONTENT_TYPE'] = str(content_type) + + return super(APIRequestFactory, self).generic( + method, path, data, content_type, secure, **extra) + def request(self, **kwargs): request = super(APIRequestFactory, self).request(**kwargs) request._dont_enforce_csrf_checks = not self.enforce_csrf_checks diff --git a/tests/test_testing.py b/tests/test_testing.py index ba42da971..1af6ef02e 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -282,4 +282,4 @@ class TestAPIRequestFactory(TestCase): data=None, content_type='application/json', ) - assert request.content_type == 'application/json' + assert request.META['CONTENT_TYPE'] == 'application/json' From fff3db5517ef80ce0ecb7448feba5aeca46d85d3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 31 Aug 2017 12:19:03 +0200 Subject: [PATCH 062/217] Fix doc for ErrorDetail --- rest_framework/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index aac31c453..7cc3ba049 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -64,7 +64,7 @@ def _get_full_details(detail): class ErrorDetail(six.text_type): """ - A string-like object that can additionally + A string-like object that can additionally have a code. """ code = None From bc49746dd37e22385facfe509bf4bb89582e7f98 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Thu, 31 Aug 2017 08:26:14 -0400 Subject: [PATCH 063/217] Fix test name --- tests/test_serializer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 3044d7c6b..af5206a9f 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -411,7 +411,7 @@ class TestDefaultOutput: serializer = self.Serializer(instance) assert serializer.data == {'has_default': 'def', 'has_default_callable': 'ghi', 'no_default': 'abc'} - def test_default_for_source_source(self): + def test_default_for_dotted_source(self): """ 'default="something"' should be used when a traversed attribute is missing from input. """ From af460d2b6906ebce0680105f36eeada867a35d7e Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 1 Sep 2017 13:37:01 -0400 Subject: [PATCH 064/217] Add PR 5376 to release notes --- docs/topics/release-notes.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 78dd334ee..f4617ac23 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -40,6 +40,10 @@ You can determine your currently installed version using `pip freeze`: ## 3.6.x series +### 3.6.5 + +* Fix `DjangoModelPermissions` to ensure user authentication before calling the view's `get_queryset()` method. As a side effect, this changes the order of the HTTP method permissions and authentication checks, and 405 responses will only be returned when authenticated. If you want to replicate the old behavior, see the PR for details. [#5376][gh5376] + ### 3.6.4 **Date**: [21st August 2017][3.6.4-milestone] @@ -1417,5 +1421,5 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh5147]: https://github.com/encode/django-rest-framework/issues/5147 [gh5131]: https://github.com/encode/django-rest-framework/issues/5131 - - + +[gh5376]: https://github.com/encode/django-rest-framework/issues/5376 From 23b2d8099bbcdf509c177c06eb56ab8b58bf5b8b Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 1 Sep 2017 13:37:58 -0400 Subject: [PATCH 065/217] Unify QS handling for model/object permissions --- rest_framework/permissions.py | 41 +++++++++++++++-------------------- tests/test_permissions.py | 23 +++++++++++++++++++- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 26728b2d6..dee0032f9 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -114,6 +114,21 @@ class DjangoModelPermissions(BasePermission): return [perm % kwargs for perm in self.perms_map[method]] + def _queryset(self, view): + assert hasattr(view, 'get_queryset') \ + or getattr(view, 'queryset', None) is not None, ( + 'Cannot apply {} on a view that does not set ' + '`.queryset` or have a `.get_queryset()` method.' + ).format(self.__class__.__name__) + + if hasattr(view, 'get_queryset'): + queryset = view.get_queryset() + assert queryset is not None, ( + '{}.get_queryset() returned None'.format(view.__class__.__name__) + ) + return queryset + return view.queryset + def has_permission(self, request, view): # Workaround to ensure DjangoModelPermissions are not applied # to the root view when using DefaultRouter. @@ -124,19 +139,7 @@ class DjangoModelPermissions(BasePermission): not is_authenticated(request.user) and self.authenticated_users_only): return False - if hasattr(view, 'get_queryset'): - queryset = view.get_queryset() - assert queryset is not None, ( - '{}.get_queryset() returned None'.format(view.__class__.__name__) - ) - else: - queryset = getattr(view, 'queryset', None) - - assert queryset is not None, ( - 'Cannot apply DjangoModelPermissions on a view that ' - 'does not set `.queryset` or have a `.get_queryset()` method.' - ) - + queryset = self._queryset(view) perms = self.get_required_permissions(request.method, queryset.model) return request.user.has_perms(perms) @@ -183,16 +186,8 @@ class DjangoObjectPermissions(DjangoModelPermissions): return [perm % kwargs for perm in self.perms_map[method]] def has_object_permission(self, request, view, obj): - if hasattr(view, 'get_queryset'): - queryset = view.get_queryset() - else: - queryset = getattr(view, 'queryset', None) - - assert queryset is not None, ( - 'Cannot apply DjangoObjectPermissions on a view that ' - 'does not set `.queryset` or have a `.get_queryset()` method.' - ) - + # authentication checks have already executed via has_permission + queryset = self._queryset(view) model_cls = queryset.model user = request.user diff --git a/tests/test_permissions.py b/tests/test_permissions.py index ed5c7af7a..f673c3671 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -9,7 +9,7 @@ from django.test import TestCase from rest_framework import ( HTTP_HEADER_ENCODING, authentication, generics, permissions, serializers, - status + status, views ) from rest_framework.compat import ResolverMatch, guardian, set_many from rest_framework.filters import DjangoObjectPermissionsFilter @@ -219,6 +219,27 @@ class ModelPermissionsIntegrationTests(TestCase): response = view(request) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + def test_queryset_assertions(self): + class View(views.APIView): + authentication_classes = [authentication.BasicAuthentication] + permission_classes = [permissions.DjangoModelPermissions] + view = View.as_view() + + request = factory.get('/', HTTP_AUTHORIZATION=self.permitted_credentials) + msg = 'Cannot apply DjangoModelPermissions on a view that does not set `.queryset` or have a `.get_queryset()` method.' + with self.assertRaisesMessage(AssertionError, msg): + view(request) + + # Faulty `get_queryset()` methods should trigger the above "view does not have a queryset" assertion. + class View(RootView): + def get_queryset(self): + return None + view = View.as_view() + + request = factory.get('/', HTTP_AUTHORIZATION=self.permitted_credentials) + with self.assertRaisesMessage(AssertionError, 'View.get_queryset() returned None'): + view(request) + class BasicPermModel(models.Model): text = models.CharField(max_length=100) From e42eb42d4912f1541bebfb220ab0a9c4d0e08c08 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 4 Sep 2017 10:04:48 +0100 Subject: [PATCH 066/217] Don't make the content mandatory in the generic content form (#5372) Sometimes, probably in the upgrade from Django 1.9 to 1.10, a post with empty content is forbidden by javascript, with the message "Please fill in this field". Filling the form with '{}' allows an application/json request to be submitted. The API call itself works perfectly well with a post with empty content: the interface shouldn't make assumptions about it. --- rest_framework/renderers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 779f0dd44..687cb0e1e 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -579,7 +579,8 @@ class BrowsableAPIRenderer(BaseRenderer): _content = forms.CharField( label='Content', widget=forms.Textarea(attrs={'data-override': 'content'}), - initial=content + initial=content, + required=False ) return GenericContentForm() From 79be20a7c68e7c90dd4d5d23a9e6ee08b5f586ae Mon Sep 17 00:00:00 2001 From: Igor Tokarev Date: Mon, 4 Sep 2017 14:11:53 +0500 Subject: [PATCH 067/217] Updated supported values for the NullBooleanField (#5387) * Updated supported values for the NullBooleanField. * Added check for unhashable types in NullBooleanField. --- rest_framework/fields.py | 33 +++++++++++++++++++++++++-------- tests/test_fields.py | 4 ++-- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5730ca571..d2079d5d6 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -688,8 +688,22 @@ class NullBooleanField(Field): 'invalid': _('"{input}" is not a valid boolean.') } initial = None - TRUE_VALUES = {'t', 'T', 'true', 'True', 'TRUE', '1', 1, True} - FALSE_VALUES = {'f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False} + TRUE_VALUES = { + 't', 'T', + 'y', 'Y', 'yes', 'YES', + 'true', 'True', 'TRUE', + 'on', 'On', 'ON', + '1', 1, + True + } + FALSE_VALUES = { + 'f', 'F', + 'n', 'N', 'no', 'NO', + 'false', 'False', 'FALSE', + 'off', 'Off', 'OFF', + '0', 0, 0.0, + False + } NULL_VALUES = {'n', 'N', 'null', 'Null', 'NULL', '', None} def __init__(self, **kwargs): @@ -698,12 +712,15 @@ class NullBooleanField(Field): super(NullBooleanField, self).__init__(**kwargs) def to_internal_value(self, data): - if data in self.TRUE_VALUES: - return True - elif data in self.FALSE_VALUES: - return False - elif data in self.NULL_VALUES: - return None + try: + if data in self.TRUE_VALUES: + return True + elif data in self.FALSE_VALUES: + return False + elif data in self.NULL_VALUES: + return None + except TypeError: # Input is an unhashable type + pass self.fail('invalid', input=data) def to_representation(self, value): diff --git a/tests/test_fields.py b/tests/test_fields.py index d6b233227..c3d2bf57d 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -587,7 +587,7 @@ class TestBooleanField(FieldValues): [], {}, ) - field = serializers.BooleanField() + field = self.field for input_value in inputs: with pytest.raises(serializers.ValidationError) as exc_info: field.run_validation(input_value) @@ -595,7 +595,7 @@ class TestBooleanField(FieldValues): assert exc_info.value.detail == expected -class TestNullBooleanField(FieldValues): +class TestNullBooleanField(TestBooleanField): """ Valid and invalid values for `BooleanField`. """ From 3c1bf6bfd5d69f36c822f92d0bb22a6f338c6431 Mon Sep 17 00:00:00 2001 From: jhg14 Date: Mon, 4 Sep 2017 11:47:53 +0100 Subject: [PATCH 068/217] Add failing test for named attribute Fix test crudely Remove comment --- rest_framework/serializers.py | 4 +++- tests/test_model_serializer.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index a4b51ae9d..b1c34b92a 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -1010,7 +1010,9 @@ class ModelSerializer(Serializer): continue extra_field_kwargs = extra_kwargs.get(field_name, {}) - source = extra_field_kwargs.get('source', '*') != '*' or field_name + source = extra_field_kwargs.get('source', '*') + if source == '*': + source = field_name # Determine the serializer field class and keyword arguments. field_class, field_kwargs = self.build_field( diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index ba3edd389..ce054f695 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -557,6 +557,39 @@ class TestRelationalFieldMappings(TestCase): self.maxDiff = None self.assertEqual(unicode_repr(TestSerializer()), expected) + def test_nested_hyperlinked_relations_named_source(self): + class TestSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = RelationalModel + depth = 1 + fields = '__all__' + + extra_kwargs = { + 'url': { + 'source': 'url' + }} + + expected = dedent(""" + TestSerializer(): + url = HyperlinkedIdentityField(source='url', view_name='relationalmodel-detail') + foreign_key = NestedSerializer(read_only=True): + url = HyperlinkedIdentityField(view_name='foreignkeytargetmodel-detail') + name = CharField(max_length=100) + one_to_one = NestedSerializer(read_only=True): + url = HyperlinkedIdentityField(view_name='onetoonetargetmodel-detail') + name = CharField(max_length=100) + many_to_many = NestedSerializer(many=True, read_only=True): + url = HyperlinkedIdentityField(view_name='manytomanytargetmodel-detail') + name = CharField(max_length=100) + through = NestedSerializer(many=True, read_only=True): + url = HyperlinkedIdentityField(view_name='throughtargetmodel-detail') + name = CharField(max_length=100) + """) + self.maxDiff = None + self.assertEqual(unicode_repr(TestSerializer()), expected) + + + def test_nested_unique_together_relations(self): class TestSerializer(serializers.HyperlinkedModelSerializer): class Meta: From 43458944452fe11132fa1ab5f2bf1934b8fc108f Mon Sep 17 00:00:00 2001 From: jhg14 Date: Mon, 4 Sep 2017 15:41:04 +0100 Subject: [PATCH 069/217] Add simplest possible failing test --- tests/test_model_serializer.py | 55 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index ce054f695..430be71c6 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -557,39 +557,6 @@ class TestRelationalFieldMappings(TestCase): self.maxDiff = None self.assertEqual(unicode_repr(TestSerializer()), expected) - def test_nested_hyperlinked_relations_named_source(self): - class TestSerializer(serializers.HyperlinkedModelSerializer): - class Meta: - model = RelationalModel - depth = 1 - fields = '__all__' - - extra_kwargs = { - 'url': { - 'source': 'url' - }} - - expected = dedent(""" - TestSerializer(): - url = HyperlinkedIdentityField(source='url', view_name='relationalmodel-detail') - foreign_key = NestedSerializer(read_only=True): - url = HyperlinkedIdentityField(view_name='foreignkeytargetmodel-detail') - name = CharField(max_length=100) - one_to_one = NestedSerializer(read_only=True): - url = HyperlinkedIdentityField(view_name='onetoonetargetmodel-detail') - name = CharField(max_length=100) - many_to_many = NestedSerializer(many=True, read_only=True): - url = HyperlinkedIdentityField(view_name='manytomanytargetmodel-detail') - name = CharField(max_length=100) - through = NestedSerializer(many=True, read_only=True): - url = HyperlinkedIdentityField(view_name='throughtargetmodel-detail') - name = CharField(max_length=100) - """) - self.maxDiff = None - self.assertEqual(unicode_repr(TestSerializer()), expected) - - - def test_nested_unique_together_relations(self): class TestSerializer(serializers.HyperlinkedModelSerializer): class Meta: @@ -1168,3 +1135,25 @@ class Test5004UniqueChoiceField(TestCase): serializer = TestUniqueChoiceSerializer(data={'name': 'choice1'}) assert not serializer.is_valid() assert serializer.errors == {'name': ['unique choice model with this name already exists.']} + +class TestFieldSource(TestCase): + + def test_named_field_source(self): + class TestSerializer(serializers.ModelSerializer): + + class Meta: + model = RegularFieldsModel + fields = ('number_field',) + extra_kwargs = { + 'number_field': { + 'source': 'integer_field' + } + } + + expected = dedent(""" + TestSerializer(): + number_field = IntegerField(source='integer_field') + """) + self.maxDiff = None + self.assertEqual(unicode_repr(TestSerializer()), expected) + From 66b2c6149ed0121b1064fe42615aaa8d75aa5d8b Mon Sep 17 00:00:00 2001 From: jhg14 Date: Mon, 4 Sep 2017 16:17:43 +0100 Subject: [PATCH 070/217] Fix code style --- tests/test_model_serializer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index 430be71c6..3411c44b5 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -1136,13 +1136,13 @@ class Test5004UniqueChoiceField(TestCase): assert not serializer.is_valid() assert serializer.errors == {'name': ['unique choice model with this name already exists.']} + class TestFieldSource(TestCase): - def test_named_field_source(self): class TestSerializer(serializers.ModelSerializer): class Meta: - model = RegularFieldsModel + model = RegularFieldsModel fields = ('number_field',) extra_kwargs = { 'number_field': { @@ -1156,4 +1156,3 @@ class TestFieldSource(TestCase): """) self.maxDiff = None self.assertEqual(unicode_repr(TestSerializer()), expected) - From b11f37eaf314b983c7a21abcea231f69ea31da1b Mon Sep 17 00:00:00 2001 From: Irvan Date: Thu, 7 Sep 2017 11:06:44 +0800 Subject: [PATCH 071/217] Fixed the MultipleFieldLookupMixin example to properly check for object level permission. --- docs/api-guide/generic-views.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 0170256f2..381f1fe73 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -330,7 +330,9 @@ For example, if you need to lookup objects based on multiple fields in the URL c for field in self.lookup_fields: if self.kwargs[field]: # Ignore empty fields. filter[field] = self.kwargs[field] - return get_object_or_404(queryset, **filter) # Lookup the object + obj = get_object_or_404(queryset, **filter) # Lookup the object + self.check_object_permissions(self.request, obj) + return obj You can then simply apply this mixin to a view or viewset anytime you need to apply the custom behavior. From 13222e45bcbf6492fee59ef85c88c3eae0a4b74e Mon Sep 17 00:00:00 2001 From: ersel-ionova <31036948+ersel-ionova@users.noreply.github.com> Date: Fri, 8 Sep 2017 16:53:17 +0100 Subject: [PATCH 072/217] Make status_code documentation more readable. (#5400) * Make status_code documentation more readable. * Update status-codes.md --- docs/api-guide/status-codes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-guide/status-codes.md b/docs/api-guide/status-codes.md index f6ec3598f..16a0e63c8 100644 --- a/docs/api-guide/status-codes.md +++ b/docs/api-guide/status-codes.md @@ -6,7 +6,7 @@ source: status.py > > — [RFC 2324][rfc2324], Hyper Text Coffee Pot Control Protocol -Using bare status codes in your responses isn't recommended. REST framework includes a set of named constants that you can use to make more code more obvious and readable. +Using bare status codes in your responses isn't recommended. REST framework includes a set of named constants that you can use to make your code more obvious and readable. from rest_framework import status from rest_framework.response import Response From 0e341c24b49c1ae8011fd4e99a13e9cb43ea64f5 Mon Sep 17 00:00:00 2001 From: Sanjuro Jogdeo Date: Fri, 8 Sep 2017 09:51:16 -0700 Subject: [PATCH 073/217] Update get_object() example in permissions.md (#5401) * Update get_object() example in permissions.md I'm a bit confused about the example that's provided in the 'Object level permissions' section. Other examples (e.g. Tutorial 3 - Class Based Views) provided a pk to get_object(). It doesn't seem like this example has any way of identifying a specific object. Just in case I'm correct, I've prepared this pull request. But if I'm wrong, would it be possible for you to explain the example I modified? Many Thanks... * Adjust patch --- docs/api-guide/permissions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md index 548b14438..ef9ce3abd 100644 --- a/docs/api-guide/permissions.md +++ b/docs/api-guide/permissions.md @@ -44,7 +44,7 @@ This will either raise a `PermissionDenied` or `NotAuthenticated` exception, or For example: def get_object(self): - obj = get_object_or_404(self.get_queryset()) + obj = get_object_or_404(self.get_queryset(), pk=self.kwargs["pk"]) self.check_object_permissions(self.request, obj) return obj From ae95ed1ec2514becb6e2e41d47b8fd3c8b9c8f66 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 11 Sep 2017 05:18:39 -0400 Subject: [PATCH 074/217] Add repr(value) to the assert msg in FieldValues --- tests/test_fields.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index c3d2bf57d..4173e6ab5 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -533,7 +533,8 @@ class FieldValues: Ensure that valid values return the expected validated data. """ for input_value, expected_output in get_items(self.valid_inputs): - assert self.field.run_validation(input_value) == expected_output + assert self.field.run_validation(input_value) == expected_output, \ + 'input value: {}'.format(repr(input_value)) def test_invalid_inputs(self): """ @@ -542,11 +543,13 @@ class FieldValues: for input_value, expected_failure in get_items(self.invalid_inputs): with pytest.raises(serializers.ValidationError) as exc_info: self.field.run_validation(input_value) - assert exc_info.value.detail == expected_failure + assert exc_info.value.detail == expected_failure, \ + 'input value: {}'.format(repr(input_value)) def test_outputs(self): for output_value, expected_output in get_items(self.outputs): - assert self.field.to_representation(output_value) == expected_output + assert self.field.to_representation(output_value) == expected_output, \ + 'output value: {}'.format(repr(output_value)) # Boolean types... From 7037ce88e94665076b33919917d44308e13ef027 Mon Sep 17 00:00:00 2001 From: Jozef Date: Tue, 12 Sep 2017 13:08:32 +0200 Subject: [PATCH 075/217] Fix throttling documentation about Remote-Addr (#5414) Clarify in docs that REMOTE_ADDR is part of the WSGI environ, not an HTTP header. --- docs/api-guide/throttling.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md index 58578a23e..10a0bb087 100644 --- a/docs/api-guide/throttling.md +++ b/docs/api-guide/throttling.md @@ -68,9 +68,9 @@ Or, if you're using the `@api_view` decorator with function based views. ## How clients are identified -The `X-Forwarded-For` and `Remote-Addr` HTTP headers are used to uniquely identify client IP addresses for throttling. If the `X-Forwarded-For` header is present then it will be used, otherwise the value of the `Remote-Addr` header will be used. +The `X-Forwarded-For` HTTP header and `REMOTE_ADDR` WSGI variable are used to uniquely identify client IP addresses for throttling. If the `X-Forwarded-For` header is present then it will be used, otherwise the value of the `REMOTE_ADDR` variable from the WSGI environment will be used. -If you need to strictly identify unique client IP addresses, you'll need to first configure the number of application proxies that the API runs behind by setting the `NUM_PROXIES` setting. This setting should be an integer of zero or more. If set to non-zero then the client IP will be identified as being the last IP address in the `X-Forwarded-For` header, once any application proxy IP addresses have first been excluded. If set to zero, then the `Remote-Addr` header will always be used as the identifying IP address. +If you need to strictly identify unique client IP addresses, you'll need to first configure the number of application proxies that the API runs behind by setting the `NUM_PROXIES` setting. This setting should be an integer of zero or more. If set to non-zero then the client IP will be identified as being the last IP address in the `X-Forwarded-For` header, once any application proxy IP addresses have first been excluded. If set to zero, then the `REMOTE_ADDR` value will always be used as the identifying IP address. It is important to understand that if you configure the `NUM_PROXIES` setting, then all clients behind a unique [NAT'd](http://en.wikipedia.org/wiki/Network_address_translation) gateway will be treated as a single client. From 9aaea2586bf5a5fab0294943d069e92969b497f2 Mon Sep 17 00:00:00 2001 From: Sergei Azarkin Date: Tue, 12 Sep 2017 16:03:29 +0300 Subject: [PATCH 076/217] Fix authtoken managment command (#5415) * Fix authtoken managment command username param --- .../authtoken/management/commands/drf_create_token.py | 2 +- tests/test_authtoken.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rest_framework/authtoken/management/commands/drf_create_token.py b/rest_framework/authtoken/management/commands/drf_create_token.py index 417bdd780..da10bfc90 100644 --- a/rest_framework/authtoken/management/commands/drf_create_token.py +++ b/rest_framework/authtoken/management/commands/drf_create_token.py @@ -19,7 +19,7 @@ class Command(BaseCommand): return token[0] def add_arguments(self, parser): - parser.add_argument('username', type=str, nargs='+') + parser.add_argument('username', type=str) parser.add_argument( '-r', diff --git a/tests/test_authtoken.py b/tests/test_authtoken.py index 6374d7141..5df053da3 100644 --- a/tests/test_authtoken.py +++ b/tests/test_authtoken.py @@ -1,7 +1,9 @@ import pytest from django.contrib.admin import site from django.contrib.auth.models import User +from django.core.management import call_command from django.test import TestCase +from django.utils.six import StringIO from rest_framework.authtoken.admin import TokenAdmin from rest_framework.authtoken.management.commands.drf_create_token import \ @@ -68,3 +70,11 @@ class AuthTokenCommandTests(TestCase): second_token_key = Token.objects.first().key assert first_token_key == second_token_key + + def test_command_output(self): + out = StringIO() + call_command('drf_create_token', self.user.username, stdout=out) + token_saved = Token.objects.first() + self.assertIn('Generated token', out.getvalue()) + self.assertIn(self.user.username, out.getvalue()) + self.assertIn(token_saved.key, out.getvalue()) From 5ea810d5268d222e1582a9a33738b2a73f88c07b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 14 Sep 2017 09:44:59 +0100 Subject: [PATCH 077/217] Drop unnecessary TODO notes. --- rest_framework/response.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/rest_framework/response.py b/rest_framework/response.py index cb0f290ce..bf0663255 100644 --- a/rest_framework/response.py +++ b/rest_framework/response.py @@ -88,8 +88,6 @@ class Response(SimpleTemplateResponse): Returns reason text corresponding to our HTTP response status code. Provided for convenience. """ - # TODO: Deprecate and use a template tag instead - # TODO: Status code text for RFC 6585 status codes return responses.get(self.status_code, '') def __getstate__(self): From d54df8c438d224616a8bcd745589b65e16db0989 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Sep 2017 10:46:34 +0200 Subject: [PATCH 078/217] Refactor schema generation to allow per-view customisation (#5354) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial Refactor Step * Add descriptor class * call from generator * proxy back to generator for implementation. * Move `get_link` to descriptor * Move `get_description` to descriptor * Remove need for generator in get_description * Move get_path_fields to descriptor * Move `get_serializer_fields` to descriptor * Move `get_pagination_fields` to descriptor * Move `get_filter_fields` to descriptor * Move `get_encoding` to descriptor. * Pass just `url` from SchemaGenerator to descriptor * Make `view` a property Encapsulates check for a view instance. * Adjust API Reference docs * Add `ManualSchema` class * Refactor to `ViewInspector` plus `AutoSchema` The interface then is **just** `get_link()` * Add `manual_fields` kwarg to AutoSchema * Add schema decorator for FBVs * Adjust comments * Docs: Provide full params in example Ref feedback https://github.com/encode/django-rest-framework/pull/5354/files/b52e372f8f936204753b17fe7c9bfb517b93a045#r137254795 * Add docstring for ViewInstpector.__get__ descriptor method. Ref https://github.com/encode/django-rest-framework/pull/5354#discussion_r137265022 * Make `schemas` a package. * Split generators, inspectors, views. * Adjust imports * Rename to EndpointEnumerator * Adjust ManualSchema to take `fields` … and `description`. Allows `url` and `action` to remain dynamic * Add package/module docstrings --- docs/api-guide/schemas.md | 270 ++++++++++-- docs/api-guide/views.md | 22 + rest_framework/decorators.py | 10 + rest_framework/routers.py | 3 +- rest_framework/schemas/__init__.py | 43 ++ .../{schemas.py => schemas/generators.py} | 347 +-------------- rest_framework/schemas/inspectors.py | 399 ++++++++++++++++++ rest_framework/schemas/utils.py | 21 + rest_framework/schemas/views.py | 34 ++ rest_framework/views.py | 2 + tests/test_decorators.py | 17 +- tests/test_schemas.py | 83 +++- 12 files changed, 868 insertions(+), 383 deletions(-) create mode 100644 rest_framework/schemas/__init__.py rename rest_framework/{schemas.py => schemas/generators.py} (51%) create mode 100644 rest_framework/schemas/inspectors.py create mode 100644 rest_framework/schemas/utils.py create mode 100644 rest_framework/schemas/views.py diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 836ad4b6a..f913f046f 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -10,7 +10,14 @@ API schemas are a useful tool that allow for a range of use cases, including generating reference documentation, or driving dynamic client libraries that can interact with your API. -## Representing schemas internally +## Install Core API + +You'll need to install the `coreapi` package in order to add schema support +for REST framework. + + pip install coreapi + +## Internal schema representation REST framework uses [Core API][coreapi] in order to model schema information in a format-independent representation. This information can then be rendered @@ -68,9 +75,34 @@ has to be rendered into the actual bytes that are used in the response. REST framework includes a renderer class for handling this media type, which is available as `renderers.CoreJSONRenderer`. +### Alternate schema formats + Other schema formats such as [Open API][open-api] ("Swagger"), -[JSON HyperSchema][json-hyperschema], or [API Blueprint][api-blueprint] can -also be supported by implementing a custom renderer class. +[JSON HyperSchema][json-hyperschema], or [API Blueprint][api-blueprint] can also +be supported by implementing a custom renderer class that handles converting a +`Document` instance into a bytestring representation. + +If there is a Core API codec package that supports encoding into the format you +want to use then implementing the renderer class can be done by using the codec. + +#### Example + +For example, the `openapi_codec` package provides support for encoding or decoding +to the Open API ("Swagger") format: + + from rest_framework import renderers + from openapi_codec import OpenAPICodec + + class SwaggerRenderer(renderers.BaseRenderer): + media_type = 'application/openapi+json' + format = 'swagger' + + def render(self, data, media_type=None, renderer_context=None): + codec = OpenAPICodec() + return codec.dump(data) + + + ## Schemas vs Hypermedia @@ -89,18 +121,121 @@ document, detailing both the current state and the available interactions. Further information and support on building Hypermedia APIs with REST framework is planned for a future version. + --- -# Adding a schema - -You'll need to install the `coreapi` package in order to add schema support -for REST framework. - - pip install coreapi +# Creating a schema REST framework includes functionality for auto-generating a schema, -or allows you to specify one explicitly. There are a few different ways to -add a schema to your API, depending on exactly what you need. +or allows you to specify one explicitly. + +## Manual Schema Specification + +To manually specify a schema you create a Core API `Document`, similar to the +example above. + + schema = coreapi.Document( + title='Flight Search API', + content={ + ... + } + ) + + +## Automatic Schema Generation + +Automatic schema generation is provided by the `SchemaGenerator` class. + +`SchemaGenerator` processes a list of routed URL pattterns and compiles the +appropriately structured Core API Document. + +Basic usage is just to provide the title for your schema and call +`get_schema()`: + + generator = schemas.SchemaGenerator(title='Flight Search API') + schema = generator.get_schema() + +### Per-View Schema Customisation + +By default, view introspection is performed by an `AutoSchema` instance +accessible via the `schema` attribute on `APIView`. This provides the +appropriate Core API `Link` object for the view, request method and path: + + auto_schema = view.schema + coreapi_link = auto_schema.get_link(...) + +(In compiling the schema, `SchemaGenerator` calls `view.schema.get_link()` for +each view, allowed method and path.) + +To customise the `Link` generation you may: + +* Instantiate `AutoSchema` on your view with the `manual_fields` kwarg: + + from rest_framework.views import APIView + from rest_framework.schemas import AutoSchema + + class CustomView(APIView): + ... + schema = AutoSchema( + manual_fields=[ + coreapi.Field("extra_field", ...), + ] + ) + + This allows extension for the most common case without subclassing. + +* Provide an `AutoSchema` subclass with more complex customisation: + + from rest_framework.views import APIView + from rest_framework.schemas import AutoSchema + + class CustomSchema(AutoSchema): + def get_link(...): + # Implemet custom introspection here (or in other sub-methods) + + class CustomView(APIView): + ... + schema = CustomSchema() + + This provides complete control over view introspection. + +* Instantiate `ManualSchema` on your view, providing the Core API `Fields` for + the view explicitly: + + from rest_framework.views import APIView + from rest_framework.schemas import ManualSchema + + class CustomView(APIView): + ... + schema = ManualSchema(fields=[ + coreapi.Field( + "first_field", + required=True, + location="path", + schema=coreschema.String() + ), + coreapi.Field( + "second_field", + required=True, + location="path", + schema=coreschema.String() + ), + ]) + + This allows manually specifying the schema for some views whilst maintaining + automatic generation elsewhere. + +--- + +**Note**: For full details on `SchemaGenerator` plus the `AutoSchema` and +`ManualSchema` descriptors see the [API Reference below](#api-reference). + +--- + +# Adding a schema view + +There are a few different ways to add a schema view to your API, depending on +exactly what you need. ## The get_schema_view shortcut @@ -342,38 +477,12 @@ A generic viewset with sections in the class docstring, using multi-line style. --- -# Alternate schema formats - -In order to support an alternate schema format, you need to implement a custom renderer -class that handles converting a `Document` instance into a bytestring representation. - -If there is a Core API codec package that supports encoding into the format you -want to use then implementing the renderer class can be done by using the codec. - -## Example - -For example, the `openapi_codec` package provides support for encoding or decoding -to the Open API ("Swagger") format: - - from rest_framework import renderers - from openapi_codec import OpenAPICodec - - class SwaggerRenderer(renderers.BaseRenderer): - media_type = 'application/openapi+json' - format = 'swagger' - - def render(self, data, media_type=None, renderer_context=None): - codec = OpenAPICodec() - return codec.dump(data) - ---- - # API Reference ## SchemaGenerator -A class that deals with introspecting your API views, which can be used to -generate a schema. +A class that walks a list of routed URL patterns, requests the schema for each view, +and collates the resulting CoreAPI Document. Typically you'll instantiate `SchemaGenerator` with a single argument, like so: @@ -406,39 +515,108 @@ Return a nested dictionary containing all the links that should be included in t This is a good point to override if you want to modify the resulting structure of the generated schema, as you can build a new dictionary with a different layout. -### get_link(self, path, method, view) + +## AutoSchema + +A class that deals with introspection of individual views for schema generation. + +`AutoSchema` is attached to `APIView` via the `schema` attribute. + +The `AutoSchema` constructor takes a single keyword argument `manual_fields`. + +**`manual_fields`**: a `list` of `coreapi.Field` instances that will be added to +the generated fields. Generated fields with a matching `name` will be overwritten. + + class CustomView(APIView): + schema = AutoSchema(manual_fields=[ + coreapi.Field( + "my_extra_field", + required=True, + location="path", + schema=coreschema.String() + ), + ]) + +For more advanced customisation subclass `AutoSchema` to customise schema generation. + + class CustomViewSchema(AutoSchema): + """ + Overrides `get_link()` to provide Custom Behavior X + """ + + def get_link(self, path, method, base_url): + link = super().get_link(path, method, base_url) + # Do something to customize link here... + return link + + class MyView(APIView): + schema = CustomViewSchema() + +The following methods are available to override. + +### get_link(self, path, method, base_url) Returns a `coreapi.Link` instance corresponding to the given view. +This is the main entry point. You can override this if you need to provide custom behaviors for particular views. -### get_description(self, path, method, view) +### get_description(self, path, method) Returns a string to use as the link description. By default this is based on the view docstring as described in the "Schemas as Documentation" section above. -### get_encoding(self, path, method, view) +### get_encoding(self, path, method) Returns a string to indicate the encoding for any request body, when interacting with the given view. Eg. `'application/json'`. May return a blank string for views that do not expect a request body. -### get_path_fields(self, path, method, view): +### get_path_fields(self, path, method): Return a list of `coreapi.Link()` instances. One for each path parameter in the URL. -### get_serializer_fields(self, path, method, view) +### get_serializer_fields(self, path, method) Return a list of `coreapi.Link()` instances. One for each field in the serializer class used by the view. -### get_pagination_fields(self, path, method, view +### get_pagination_fields(self, path, method) Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fields()` method on any pagination class used by the view. -### get_filter_fields(self, path, method, view) +### get_filter_fields(self, path, method) Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fields()` method of any filter classes used by the view. + +## ManualSchema + +Allows manually providing a list of `coreapi.Field` instances for the schema, +plus an optional description. + + class MyView(APIView): + schema = ManualSchema(fields=[ + coreapi.Field( + "first_field", + required=True, + location="path", + schema=coreschema.String() + ), + coreapi.Field( + "second_field", + required=True, + location="path", + schema=coreschema.String() + ), + ] + ) + +The `ManualSchema` constructor takes two arguments: + +**`fields`**: A list of `coreapi.Field` instances. Required. + +**`description`**: A string description. Optional. + --- ## Core API diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 4fa36d0fc..24dd42578 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -184,6 +184,28 @@ The available decorators are: Each of these decorators takes a single argument which must be a list or tuple of classes. + +## View schema decorator + +To override the default schema generation for function based views you may use +the `@schema` decorator. This must come *after* (below) the `@api_view` +decorator. For example: + + from rest_framework.decorators import api_view, schema + from rest_framework.schemas import AutoSchema + + class CustomAutoSchema(AutoSchema): + def get_link(self, path, method, base_url): + # override view introspection here... + + @api_view(['GET']) + @schema(CustomAutoSchema()) + def view(request): + return Response({"message": "Hello for today! See you tomorrow!"}) + +This decorator takes a single `AutoSchema` instance, an `AutoSchema` subclass +instance or `ManualSchema` instance as described in the [Schemas documentation][schemas], + [cite]: http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html [cite2]: http://www.boredomandlaziness.org/2012/05/djangos-cbvs-are-not-mistake-but.html [settings]: settings.md diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index bf9b32aaa..1297f96b4 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -72,6 +72,9 @@ def api_view(http_method_names=None, exclude_from_schema=False): WrappedAPIView.permission_classes = getattr(func, 'permission_classes', APIView.permission_classes) + WrappedAPIView.schema = getattr(func, 'schema', + APIView.schema) + WrappedAPIView.exclude_from_schema = exclude_from_schema return WrappedAPIView.as_view() return decorator @@ -112,6 +115,13 @@ def permission_classes(permission_classes): return decorator +def schema(view_inspector): + def decorator(func): + func.schema = view_inspector + return func + return decorator + + def detail_route(methods=None, **kwargs): """ Used to mark a method on a ViewSet that should be routed for detail requests. diff --git a/rest_framework/routers.py b/rest_framework/routers.py index a04bffc1a..01daa7e7d 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -26,7 +26,8 @@ from rest_framework import views from rest_framework.compat import NoReverseMatch from rest_framework.response import Response from rest_framework.reverse import reverse -from rest_framework.schemas import SchemaGenerator, SchemaView +from rest_framework.schemas import SchemaGenerator +from rest_framework.schemas.views import SchemaView from rest_framework.settings import api_settings from rest_framework.urlpatterns import format_suffix_patterns diff --git a/rest_framework/schemas/__init__.py b/rest_framework/schemas/__init__.py new file mode 100644 index 000000000..fc551640e --- /dev/null +++ b/rest_framework/schemas/__init__.py @@ -0,0 +1,43 @@ +""" +rest_framework.schemas + +schemas: + __init__.py + generators.py # Top-down schema generation + inspectors.py # Per-endpoint view introspection + utils.py # Shared helper functions + views.py # Houses `SchemaView`, `APIView` subclass. + +We expose a minimal "public" API directly from `schemas`. This covers the +basic use-cases: + + from rest_framework.schemas import ( + AutoSchema, + ManualSchema, + get_schema_view, + SchemaGenerator, + ) + +Other access should target the submodules directly +""" +from .generators import SchemaGenerator +from .inspectors import AutoSchema, ManualSchema # noqa + + +def get_schema_view( + title=None, url=None, description=None, urlconf=None, renderer_classes=None, + public=False, patterns=None, generator_class=SchemaGenerator): + """ + Return a schema view. + """ + # Avoid import cycle on APIView + from .views import SchemaView + generator = generator_class( + title=title, url=url, description=description, + urlconf=urlconf, patterns=patterns, + ) + return SchemaView.as_view( + renderer_classes=renderer_classes, + schema_generator=generator, + public=public, + ) diff --git a/rest_framework/schemas.py b/rest_framework/schemas/generators.py similarity index 51% rename from rest_framework/schemas.py rename to rest_framework/schemas/generators.py index 437413355..8344f64f0 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas/generators.py @@ -1,86 +1,26 @@ -import re +""" +generators.py # Top-down schema generation + +See schemas.__init__.py for package overview. +""" from collections import OrderedDict from importlib import import_module from django.conf import settings from django.contrib.admindocs.views import simplify_regex from django.core.exceptions import PermissionDenied -from django.db import models from django.http import Http404 from django.utils import six -from django.utils.encoding import force_text, smart_text -from django.utils.translation import ugettext_lazy as _ -from rest_framework import exceptions, renderers, serializers +from rest_framework import exceptions from rest_framework.compat import ( - RegexURLPattern, RegexURLResolver, coreapi, coreschema, uritemplate, - urlparse + RegexURLPattern, RegexURLResolver, coreapi, coreschema ) from rest_framework.request import clone_request -from rest_framework.response import Response from rest_framework.settings import api_settings -from rest_framework.utils import formatting from rest_framework.utils.model_meta import _get_pk -from rest_framework.views import APIView -header_regex = re.compile('^[a-zA-Z][0-9A-Za-z_]*:') - - -def field_to_schema(field): - title = force_text(field.label) if field.label else '' - description = force_text(field.help_text) if field.help_text else '' - - if isinstance(field, (serializers.ListSerializer, serializers.ListField)): - child_schema = field_to_schema(field.child) - return coreschema.Array( - items=child_schema, - title=title, - description=description - ) - elif isinstance(field, serializers.Serializer): - return coreschema.Object( - properties=OrderedDict([ - (key, field_to_schema(value)) - for key, value - in field.fields.items() - ]), - title=title, - description=description - ) - elif isinstance(field, serializers.ManyRelatedField): - return coreschema.Array( - items=coreschema.String(), - title=title, - description=description - ) - elif isinstance(field, serializers.RelatedField): - return coreschema.String(title=title, description=description) - elif isinstance(field, serializers.MultipleChoiceField): - return coreschema.Array( - items=coreschema.Enum(enum=list(field.choices.keys())), - title=title, - description=description - ) - elif isinstance(field, serializers.ChoiceField): - return coreschema.Enum( - enum=list(field.choices.keys()), - title=title, - description=description - ) - elif isinstance(field, serializers.BooleanField): - return coreschema.Boolean(title=title, description=description) - elif isinstance(field, (serializers.DecimalField, serializers.FloatField)): - return coreschema.Number(title=title, description=description) - elif isinstance(field, serializers.IntegerField): - return coreschema.Integer(title=title, description=description) - - if field.style.get('base_template') == 'textarea.html': - return coreschema.String( - title=title, - description=description, - format='textarea' - ) - return coreschema.String(title=title, description=description) +from .utils import is_list_view def common_path(paths): @@ -104,6 +44,8 @@ def is_api_view(callback): """ Return `True` if the given view callback is a REST framework view/viewset. """ + # Avoid import cycle on APIView + from rest_framework.views import APIView cls = getattr(callback, 'cls', None) return (cls is not None) and issubclass(cls, APIView) @@ -130,22 +72,6 @@ def is_custom_action(action): ]) -def is_list_view(path, method, view): - """ - Return True if the given path/method appears to represent a list view. - """ - if hasattr(view, 'action'): - # Viewsets have an explicitly defined action, which we can inspect. - return view.action == 'list' - - if method.lower() != 'get': - return False - path_components = path.strip('/').split('/') - if path_components and '{' in path_components[-1]: - return False - return True - - def endpoint_ordering(endpoint): path, method, callback = endpoint method_priority = { @@ -158,21 +84,7 @@ def endpoint_ordering(endpoint): return (path, method_priority) -def get_pk_description(model, model_field): - if isinstance(model_field, models.AutoField): - value_type = _('unique integer value') - elif isinstance(model_field, models.UUIDField): - value_type = _('UUID string') - else: - value_type = _('unique value') - - return _('A {value_type} identifying this {name}.').format( - value_type=value_type, - name=model._meta.verbose_name, - ) - - -class EndpointInspector(object): +class EndpointEnumerator(object): """ A class to determine the available API endpoints that a project exposes. """ @@ -265,7 +177,7 @@ class SchemaGenerator(object): 'patch': 'partial_update', 'delete': 'destroy', } - endpoint_inspector_cls = EndpointInspector + endpoint_inspector_cls = EndpointEnumerator # Map the method names we use for viewset actions onto external schema names. # These give us names that are more suitable for the external representation. @@ -341,7 +253,7 @@ class SchemaGenerator(object): for path, method, view in view_endpoints: if not self.has_view_permissions(path, method, view): continue - link = self.get_link(path, method, view) + link = view.schema.get_link(path, method, base_url=self.url) subpath = path[len(prefix):] keys = self.get_keys(subpath, method, view) insert_into(links, keys, link) @@ -433,197 +345,6 @@ class SchemaGenerator(object): field_name = 'id' return path.replace('{pk}', '{%s}' % field_name) - # Methods for generating each individual `Link` instance... - - def get_link(self, path, method, view): - """ - Return a `coreapi.Link` instance for the given endpoint. - """ - fields = self.get_path_fields(path, method, view) - fields += self.get_serializer_fields(path, method, view) - fields += self.get_pagination_fields(path, method, view) - fields += self.get_filter_fields(path, method, view) - - if fields and any([field.location in ('form', 'body') for field in fields]): - encoding = self.get_encoding(path, method, view) - else: - encoding = None - - description = self.get_description(path, method, view) - - if self.url and path.startswith('/'): - path = path[1:] - - return coreapi.Link( - url=urlparse.urljoin(self.url, path), - action=method.lower(), - encoding=encoding, - fields=fields, - description=description - ) - - def get_description(self, path, method, view): - """ - Determine a link description. - - This will be based on the method docstring if one exists, - or else the class docstring. - """ - method_name = getattr(view, 'action', method.lower()) - method_docstring = getattr(view, method_name, None).__doc__ - if method_docstring: - # An explicit docstring on the method or action. - return formatting.dedent(smart_text(method_docstring)) - - description = view.get_view_description() - lines = [line.strip() for line in description.splitlines()] - current_section = '' - sections = {'': ''} - - for line in lines: - if header_regex.match(line): - current_section, seperator, lead = line.partition(':') - sections[current_section] = lead.strip() - else: - sections[current_section] += '\n' + line - - header = getattr(view, 'action', method.lower()) - if header in sections: - return sections[header].strip() - if header in self.coerce_method_names: - if self.coerce_method_names[header] in sections: - return sections[self.coerce_method_names[header]].strip() - return sections[''].strip() - - def get_encoding(self, path, method, view): - """ - Return the 'encoding' parameter to use for a given endpoint. - """ - # Core API supports the following request encodings over HTTP... - supported_media_types = set(( - 'application/json', - 'application/x-www-form-urlencoded', - 'multipart/form-data', - )) - parser_classes = getattr(view, 'parser_classes', []) - for parser_class in parser_classes: - media_type = getattr(parser_class, 'media_type', None) - if media_type in supported_media_types: - return media_type - # Raw binary uploads are supported with "application/octet-stream" - if media_type == '*/*': - return 'application/octet-stream' - - return None - - def get_path_fields(self, path, method, view): - """ - Return a list of `coreapi.Field` instances corresponding to any - templated path variables. - """ - model = getattr(getattr(view, 'queryset', None), 'model', None) - fields = [] - - for variable in uritemplate.variables(path): - title = '' - description = '' - schema_cls = coreschema.String - kwargs = {} - if model is not None: - # Attempt to infer a field description if possible. - try: - model_field = model._meta.get_field(variable) - except: - model_field = None - - if model_field is not None and model_field.verbose_name: - title = force_text(model_field.verbose_name) - - if model_field is not None and model_field.help_text: - description = force_text(model_field.help_text) - elif model_field is not None and model_field.primary_key: - description = get_pk_description(model, model_field) - - if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable: - kwargs['pattern'] = view.lookup_value_regex - elif isinstance(model_field, models.AutoField): - schema_cls = coreschema.Integer - - field = coreapi.Field( - name=variable, - location='path', - required=True, - schema=schema_cls(title=title, description=description, **kwargs) - ) - fields.append(field) - - return fields - - def get_serializer_fields(self, path, method, view): - """ - Return a list of `coreapi.Field` instances corresponding to any - request body input, as determined by the serializer class. - """ - if method not in ('PUT', 'PATCH', 'POST'): - return [] - - if not hasattr(view, 'get_serializer'): - return [] - - serializer = view.get_serializer() - - if isinstance(serializer, serializers.ListSerializer): - return [ - coreapi.Field( - name='data', - location='body', - required=True, - schema=coreschema.Array() - ) - ] - - if not isinstance(serializer, serializers.Serializer): - return [] - - fields = [] - for field in serializer.fields.values(): - if field.read_only or isinstance(field, serializers.HiddenField): - continue - - required = field.required and method != 'PATCH' - field = coreapi.Field( - name=field.field_name, - location='form', - required=required, - schema=field_to_schema(field) - ) - fields.append(field) - - return fields - - def get_pagination_fields(self, path, method, view): - if not is_list_view(path, method, view): - return [] - - pagination = getattr(view, 'pagination_class', None) - if not pagination: - return [] - - paginator = view.pagination_class() - return paginator.get_schema_fields(view) - - def get_filter_fields(self, path, method, view): - if not is_list_view(path, method, view): - return [] - - if not getattr(view, 'filter_backends', None): - return [] - - fields = [] - for filter_backend in view.filter_backends: - fields += filter_backend().get_schema_fields(view) - return fields - # Method for generating the link layout.... def get_keys(self, subpath, method, view): @@ -669,45 +390,3 @@ class SchemaGenerator(object): # Default action, eg "/users/", "/users/{pk}/" return named_path_components + [action] - - -class SchemaView(APIView): - _ignore_model_permissions = True - exclude_from_schema = True - renderer_classes = None - schema_generator = None - public = False - - def __init__(self, *args, **kwargs): - super(SchemaView, self).__init__(*args, **kwargs) - if self.renderer_classes is None: - if renderers.BrowsableAPIRenderer in api_settings.DEFAULT_RENDERER_CLASSES: - self.renderer_classes = [ - renderers.CoreJSONRenderer, - renderers.BrowsableAPIRenderer, - ] - else: - self.renderer_classes = [renderers.CoreJSONRenderer] - - def get(self, request, *args, **kwargs): - schema = self.schema_generator.get_schema(request, self.public) - if schema is None: - raise exceptions.PermissionDenied() - return Response(schema) - - -def get_schema_view( - title=None, url=None, description=None, urlconf=None, renderer_classes=None, - public=False, patterns=None, generator_class=SchemaGenerator): - """ - Return a schema view. - """ - generator = generator_class( - title=title, url=url, description=description, - urlconf=urlconf, patterns=patterns, - ) - return SchemaView.as_view( - renderer_classes=renderer_classes, - schema_generator=generator, - public=public, - ) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py new file mode 100644 index 000000000..cd9fa73da --- /dev/null +++ b/rest_framework/schemas/inspectors.py @@ -0,0 +1,399 @@ +""" +inspectors.py # Per-endpoint view introspection + +See schemas.__init__.py for package overview. +""" +import re +from collections import OrderedDict + +from django.db import models +from django.utils.encoding import force_text, smart_text +from django.utils.translation import ugettext_lazy as _ + +from rest_framework import serializers +from rest_framework.compat import coreapi, coreschema, uritemplate, urlparse +from rest_framework.settings import api_settings +from rest_framework.utils import formatting + +from .utils import is_list_view + +header_regex = re.compile('^[a-zA-Z][0-9A-Za-z_]*:') + + +def field_to_schema(field): + title = force_text(field.label) if field.label else '' + description = force_text(field.help_text) if field.help_text else '' + + if isinstance(field, (serializers.ListSerializer, serializers.ListField)): + child_schema = field_to_schema(field.child) + return coreschema.Array( + items=child_schema, + title=title, + description=description + ) + elif isinstance(field, serializers.Serializer): + return coreschema.Object( + properties=OrderedDict([ + (key, field_to_schema(value)) + for key, value + in field.fields.items() + ]), + title=title, + description=description + ) + elif isinstance(field, serializers.ManyRelatedField): + return coreschema.Array( + items=coreschema.String(), + title=title, + description=description + ) + elif isinstance(field, serializers.RelatedField): + return coreschema.String(title=title, description=description) + elif isinstance(field, serializers.MultipleChoiceField): + return coreschema.Array( + items=coreschema.Enum(enum=list(field.choices.keys())), + title=title, + description=description + ) + elif isinstance(field, serializers.ChoiceField): + return coreschema.Enum( + enum=list(field.choices.keys()), + title=title, + description=description + ) + elif isinstance(field, serializers.BooleanField): + return coreschema.Boolean(title=title, description=description) + elif isinstance(field, (serializers.DecimalField, serializers.FloatField)): + return coreschema.Number(title=title, description=description) + elif isinstance(field, serializers.IntegerField): + return coreschema.Integer(title=title, description=description) + + if field.style.get('base_template') == 'textarea.html': + return coreschema.String( + title=title, + description=description, + format='textarea' + ) + return coreschema.String(title=title, description=description) + + +def get_pk_description(model, model_field): + if isinstance(model_field, models.AutoField): + value_type = _('unique integer value') + elif isinstance(model_field, models.UUIDField): + value_type = _('UUID string') + else: + value_type = _('unique value') + + return _('A {value_type} identifying this {name}.').format( + value_type=value_type, + name=model._meta.verbose_name, + ) + + +class ViewInspector(object): + """ + Descriptor class on APIView. + + Provide subclass for per-view schema generation + """ + def __get__(self, instance, owner): + """ + Enables `ViewInspector` as a Python _Descriptor_. + + This is how `view.schema` knows about `view`. + + `__get__` is called when the descriptor is accessed on the owner. + (That will be when view.schema is called in our case.) + + `owner` is always the owner class. (An APIView, or subclass for us.) + `instance` is the view instance or `None` if accessed from the class, + rather than an instance. + + See: https://docs.python.org/3/howto/descriptor.html for info on + descriptor usage. + """ + self.view = instance + return self + + @property + def view(self): + """View property.""" + assert self._view is not None, "Schema generation REQUIRES a view instance. (Hint: you accessed `schema` from the view class rather than an instance.)" + return self._view + + @view.setter + def view(self, value): + self._view = value + + @view.deleter + def view(self): + self._view = None + + def get_link(self, path, method, base_url): + """ + Generate `coreapi.Link` for self.view, path and method. + + This is the main _public_ access point. + + Parameters: + + * path: Route path for view from URLConf. + * method: The HTTP request method. + * base_url: The project "mount point" as given to SchemaGenerator + """ + raise NotImplementedError(".get_link() must be overridden.") + + +class AutoSchema(ViewInspector): + """ + Default inspector for APIView + + Responsible for per-view instrospection and schema generation. + """ + def __init__(self, manual_fields=None): + """ + Parameters: + + * `manual_fields`: list of `coreapi.Field` instances that + will be added to auto-generated fields, overwriting on `Field.name` + """ + + self._manual_fields = manual_fields + + def get_link(self, path, method, base_url): + fields = self.get_path_fields(path, method) + fields += self.get_serializer_fields(path, method) + fields += self.get_pagination_fields(path, method) + fields += self.get_filter_fields(path, method) + + if self._manual_fields is not None: + by_name = {f.name: f for f in fields} + for f in self._manual_fields: + by_name[f.name] = f + fields = list(by_name.values()) + + if fields and any([field.location in ('form', 'body') for field in fields]): + encoding = self.get_encoding(path, method) + else: + encoding = None + + description = self.get_description(path, method) + + if base_url and path.startswith('/'): + path = path[1:] + + return coreapi.Link( + url=urlparse.urljoin(base_url, path), + action=method.lower(), + encoding=encoding, + fields=fields, + description=description + ) + + def get_description(self, path, method): + """ + Determine a link description. + + This will be based on the method docstring if one exists, + or else the class docstring. + """ + view = self.view + + method_name = getattr(view, 'action', method.lower()) + method_docstring = getattr(view, method_name, None).__doc__ + if method_docstring: + # An explicit docstring on the method or action. + return formatting.dedent(smart_text(method_docstring)) + + description = view.get_view_description() + lines = [line.strip() for line in description.splitlines()] + current_section = '' + sections = {'': ''} + + for line in lines: + if header_regex.match(line): + current_section, seperator, lead = line.partition(':') + sections[current_section] = lead.strip() + else: + sections[current_section] += '\n' + line + + # TODO: SCHEMA_COERCE_METHOD_NAMES appears here and in `SchemaGenerator.get_keys` + coerce_method_names = api_settings.SCHEMA_COERCE_METHOD_NAMES + header = getattr(view, 'action', method.lower()) + if header in sections: + return sections[header].strip() + if header in coerce_method_names: + if coerce_method_names[header] in sections: + return sections[coerce_method_names[header]].strip() + return sections[''].strip() + + def get_path_fields(self, path, method): + """ + Return a list of `coreapi.Field` instances corresponding to any + templated path variables. + """ + view = self.view + model = getattr(getattr(view, 'queryset', None), 'model', None) + fields = [] + + for variable in uritemplate.variables(path): + title = '' + description = '' + schema_cls = coreschema.String + kwargs = {} + if model is not None: + # Attempt to infer a field description if possible. + try: + model_field = model._meta.get_field(variable) + except: + model_field = None + + if model_field is not None and model_field.verbose_name: + title = force_text(model_field.verbose_name) + + if model_field is not None and model_field.help_text: + description = force_text(model_field.help_text) + elif model_field is not None and model_field.primary_key: + description = get_pk_description(model, model_field) + + if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable: + kwargs['pattern'] = view.lookup_value_regex + elif isinstance(model_field, models.AutoField): + schema_cls = coreschema.Integer + + field = coreapi.Field( + name=variable, + location='path', + required=True, + schema=schema_cls(title=title, description=description, **kwargs) + ) + fields.append(field) + + return fields + + def get_serializer_fields(self, path, method): + """ + Return a list of `coreapi.Field` instances corresponding to any + request body input, as determined by the serializer class. + """ + view = self.view + + if method not in ('PUT', 'PATCH', 'POST'): + return [] + + if not hasattr(view, 'get_serializer'): + return [] + + serializer = view.get_serializer() + + if isinstance(serializer, serializers.ListSerializer): + return [ + coreapi.Field( + name='data', + location='body', + required=True, + schema=coreschema.Array() + ) + ] + + if not isinstance(serializer, serializers.Serializer): + return [] + + fields = [] + for field in serializer.fields.values(): + if field.read_only or isinstance(field, serializers.HiddenField): + continue + + required = field.required and method != 'PATCH' + field = coreapi.Field( + name=field.field_name, + location='form', + required=required, + schema=field_to_schema(field) + ) + fields.append(field) + + return fields + + def get_pagination_fields(self, path, method): + view = self.view + + if not is_list_view(path, method, view): + return [] + + pagination = getattr(view, 'pagination_class', None) + if not pagination: + return [] + + paginator = view.pagination_class() + return paginator.get_schema_fields(view) + + def get_filter_fields(self, path, method): + view = self.view + + if not is_list_view(path, method, view): + return [] + + if not getattr(view, 'filter_backends', None): + return [] + + fields = [] + for filter_backend in view.filter_backends: + fields += filter_backend().get_schema_fields(view) + return fields + + def get_encoding(self, path, method): + """ + Return the 'encoding' parameter to use for a given endpoint. + """ + view = self.view + + # Core API supports the following request encodings over HTTP... + supported_media_types = set(( + 'application/json', + 'application/x-www-form-urlencoded', + 'multipart/form-data', + )) + parser_classes = getattr(view, 'parser_classes', []) + for parser_class in parser_classes: + media_type = getattr(parser_class, 'media_type', None) + if media_type in supported_media_types: + return media_type + # Raw binary uploads are supported with "application/octet-stream" + if media_type == '*/*': + return 'application/octet-stream' + + return None + + +class ManualSchema(ViewInspector): + """ + Allows providing a list of coreapi.Fields, + plus an optional description. + """ + def __init__(self, fields, description=''): + """ + Parameters: + + * `fields`: list of `coreapi.Field` instances. + * `descripton`: String description for view. Optional. + """ + assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances" + self._fields = fields + self._description = description + + def get_link(self, path, method, base_url): + + if base_url and path.startswith('/'): + path = path[1:] + + return coreapi.Link( + url=urlparse.urljoin(base_url, path), + action=method.lower(), + encoding=None, + fields=self._fields, + description=self._description + ) + + return self._link diff --git a/rest_framework/schemas/utils.py b/rest_framework/schemas/utils.py new file mode 100644 index 000000000..1542b6154 --- /dev/null +++ b/rest_framework/schemas/utils.py @@ -0,0 +1,21 @@ +""" +utils.py # Shared helper functions + +See schemas.__init__.py for package overview. +""" + + +def is_list_view(path, method, view): + """ + Return True if the given path/method appears to represent a list view. + """ + if hasattr(view, 'action'): + # Viewsets have an explicitly defined action, which we can inspect. + return view.action == 'list' + + if method.lower() != 'get': + return False + path_components = path.strip('/').split('/') + if path_components and '{' in path_components[-1]: + return False + return True diff --git a/rest_framework/schemas/views.py b/rest_framework/schemas/views.py new file mode 100644 index 000000000..932b5a487 --- /dev/null +++ b/rest_framework/schemas/views.py @@ -0,0 +1,34 @@ +""" +views.py # Houses `SchemaView`, `APIView` subclass. + +See schemas.__init__.py for package overview. +""" +from rest_framework import exceptions, renderers +from rest_framework.response import Response +from rest_framework.settings import api_settings +from rest_framework.views import APIView + + +class SchemaView(APIView): + _ignore_model_permissions = True + exclude_from_schema = True + renderer_classes = None + schema_generator = None + public = False + + def __init__(self, *args, **kwargs): + super(SchemaView, self).__init__(*args, **kwargs) + if self.renderer_classes is None: + if renderers.BrowsableAPIRenderer in api_settings.DEFAULT_RENDERER_CLASSES: + self.renderer_classes = [ + renderers.CoreJSONRenderer, + renderers.BrowsableAPIRenderer, + ] + else: + self.renderer_classes = [renderers.CoreJSONRenderer] + + def get(self, request, *args, **kwargs): + schema = self.schema_generator.get_schema(request, self.public) + if schema is None: + raise exceptions.PermissionDenied() + return Response(schema) diff --git a/rest_framework/views.py b/rest_framework/views.py index 8ec5f14ab..ccc2047ee 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -19,6 +19,7 @@ from rest_framework import exceptions, status from rest_framework.compat import set_rollback from rest_framework.request import Request from rest_framework.response import Response +from rest_framework.schemas import AutoSchema from rest_framework.settings import api_settings from rest_framework.utils import formatting @@ -113,6 +114,7 @@ class APIView(View): # Mark the view as being included or excluded from schema generation. exclude_from_schema = False + schema = AutoSchema() @classmethod def as_view(cls, **initkwargs): diff --git a/tests/test_decorators.py b/tests/test_decorators.py index b187e5fd6..6331742db 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -6,12 +6,13 @@ from rest_framework import status from rest_framework.authentication import BasicAuthentication from rest_framework.decorators import ( api_view, authentication_classes, parser_classes, permission_classes, - renderer_classes, throttle_classes + renderer_classes, schema, throttle_classes ) from rest_framework.parsers import JSONParser from rest_framework.permissions import IsAuthenticated from rest_framework.renderers import JSONRenderer from rest_framework.response import Response +from rest_framework.schemas import AutoSchema from rest_framework.test import APIRequestFactory from rest_framework.throttling import UserRateThrottle from rest_framework.views import APIView @@ -151,3 +152,17 @@ class DecoratorTestCase(TestCase): response = view(request) assert response.status_code == status.HTTP_429_TOO_MANY_REQUESTS + + def test_schema(self): + """ + Checks CustomSchema class is set on view + """ + class CustomSchema(AutoSchema): + pass + + @api_view(['GET']) + @schema(CustomSchema()) + def view(request): + return Response({}) + + assert isinstance(view.cls.schema, CustomSchema) diff --git a/tests/test_schemas.py b/tests/test_schemas.py index b435dfdd7..14ed0f6b6 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -1,5 +1,6 @@ import unittest +import pytest from django.conf.urls import include, url from django.core.exceptions import PermissionDenied from django.http import Http404 @@ -10,7 +11,9 @@ from rest_framework.compat import coreapi, coreschema from rest_framework.decorators import detail_route, list_route from rest_framework.request import Request from rest_framework.routers import DefaultRouter -from rest_framework.schemas import SchemaGenerator, get_schema_view +from rest_framework.schemas import ( + AutoSchema, ManualSchema, SchemaGenerator, get_schema_view +) from rest_framework.test import APIClient, APIRequestFactory from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet @@ -496,3 +499,81 @@ class Test4605Regression(TestCase): '/auth/convert-token/' ]) assert prefix == '/' + + +class TestDescriptor(TestCase): + + def test_apiview_schema_descriptor(self): + view = APIView() + assert hasattr(view, 'schema') + assert isinstance(view.schema, AutoSchema) + + def test_get_link_requires_instance(self): + descriptor = APIView.schema # Accessed from class + with pytest.raises(AssertionError): + descriptor.get_link(None, None, None) # ???: Do the dummy arguments require a tighter assert? + + def test_manual_fields(self): + + class CustomView(APIView): + schema = AutoSchema(manual_fields=[ + coreapi.Field( + "my_extra_field", + required=True, + location="path", + schema=coreschema.String() + ), + ]) + + view = CustomView() + link = view.schema.get_link('/a/url/{id}/', 'GET', '') + fields = link.fields + + assert len(fields) == 2 + assert "my_extra_field" in [f.name for f in fields] + + def test_view_with_manual_schema(self): + + path = '/example' + method = 'get' + base_url = None + + fields = [ + coreapi.Field( + "first_field", + required=True, + location="path", + schema=coreschema.String() + ), + coreapi.Field( + "second_field", + required=True, + location="path", + schema=coreschema.String() + ), + coreapi.Field( + "third_field", + required=True, + location="path", + schema=coreschema.String() + ), + ] + description = "A test endpoint" + + class CustomView(APIView): + """ + ManualSchema takes list of fields for endpoint. + - Provides url and action, which are always dynamic + """ + schema = ManualSchema(fields, description) + + expected = coreapi.Link( + url=path, + action=method, + fields=fields, + description=description + ) + + view = CustomView() + link = view.schema.get_link(path, method, base_url) + assert link == expected From efff9ff338bb0994b3249fa9907bb7018d7b6d5e Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Sep 2017 13:20:41 +0200 Subject: [PATCH 079/217] 5378 fix schema generation markdown (#5421) * Test case for #5240 * Remove unnecessary strip() from get_description Closes #5240 * Adjust test case --- rest_framework/schemas/inspectors.py | 2 +- tests/test_schemas.py | 36 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index cd9fa73da..a91205cde 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -207,7 +207,7 @@ class AutoSchema(ViewInspector): return formatting.dedent(smart_text(method_docstring)) description = view.get_view_description() - lines = [line.strip() for line in description.splitlines()] + lines = [line for line in description.splitlines()] current_section = '' sections = {'': ''} diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 14ed0f6b6..f8a63aa89 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -15,6 +15,7 @@ from rest_framework.schemas import ( AutoSchema, ManualSchema, SchemaGenerator, get_schema_view ) from rest_framework.test import APIClient, APIRequestFactory +from rest_framework.utils import formatting from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet @@ -577,3 +578,38 @@ class TestDescriptor(TestCase): view = CustomView() link = view.schema.get_link(path, method, base_url) assert link == expected + + +def test_docstring_is_not_stripped_by_get_description(): + class ExampleDocstringAPIView(APIView): + """ + === title + + * item a + * item a-a + * item a-b + * item b + + - item 1 + - item 2 + + code block begin + code + code + code + code block end + + the end + """ + + def get(self, *args, **kwargs): + pass + + def post(self, request, *args, **kwargs): + pass + + view = ExampleDocstringAPIView() + schema = view.schema + descr = schema.get_description('example', 'get') + # the first and last character are '\n' correctly removed by get_description + assert descr == formatting.dedent(ExampleDocstringAPIView.__doc__[1:][:-1]) From 7b1582e00e91001ec07cd394520ec5cdd2c2add1 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 20 Sep 2017 11:29:47 +0200 Subject: [PATCH 080/217] Allow `schema = None`. Deprecate `exclude_from_schema` (#5422) * Add tests for schema exclusions * Move exclusion check to should_include_endpoint * Update docs * Switch to using `schema = None` * Test PendingDeprecationWarnings * Add note to release notes. * s/deprecated/pending deprecation/ * Add PR link to release notes * Correct typo in test class name * Test 'exclude_from_schema' deprecation warning message (#1) * Correct deprecation warning message --- docs/api-guide/schemas.md | 6 ++ docs/api-guide/views.md | 17 +++-- docs/topics/release-notes.md | 3 + rest_framework/decorators.py | 10 ++- rest_framework/routers.py | 2 +- rest_framework/schemas/generators.py | 14 +++- rest_framework/schemas/views.py | 2 +- rest_framework/views.py | 2 - tests/test_schemas.py | 109 ++++++++++++++++++++++++++- 9 files changed, 149 insertions(+), 16 deletions(-) diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index f913f046f..fc848199c 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -225,6 +225,12 @@ To customise the `Link` generation you may: This allows manually specifying the schema for some views whilst maintaining automatic generation elsewhere. +You may disable schema generation for a view by setting `schema` to `None`: + + class CustomView(APIView): + ... + schema = None # Will not appear in schema + --- **Note**: For full details on `SchemaGenerator` plus the `AutoSchema` and diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 24dd42578..2f9f51cf9 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -130,7 +130,7 @@ REST framework also allows you to work with regular function based views. It pr ## @api_view() -**Signature:** `@api_view(http_method_names=['GET'], exclude_from_schema=False)` +**Signature:** `@api_view(http_method_names=['GET'])` The core of this functionality is the `api_view` decorator, which takes a list of HTTP methods that your view should respond to. For example, this is how you would write a very simple view that just manually returns some data: @@ -150,12 +150,6 @@ By default only `GET` methods will be accepted. Other methods will respond with return Response({"message": "Got some data!", "data": request.data}) return Response({"message": "Hello, world!"}) -You can also mark an API view as being omitted from any [auto-generated schema][schemas], -using the `exclude_from_schema` argument.: - - @api_view(['GET'], exclude_from_schema=True) - def api_docs(request): - ... ## API policy decorators @@ -204,7 +198,14 @@ decorator. For example: return Response({"message": "Hello for today! See you tomorrow!"}) This decorator takes a single `AutoSchema` instance, an `AutoSchema` subclass -instance or `ManualSchema` instance as described in the [Schemas documentation][schemas], +instance or `ManualSchema` instance as described in the [Schemas documentation][schemas]. +You may pass `None` in order to exclude the view from schema generation. + + @api_view(['GET']) + @schema(None) + def view(request): + return Response({"message": "Will not appear in schema!"}) + [cite]: http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html [cite2]: http://www.boredomandlaziness.org/2012/05/djangos-cbvs-are-not-mistake-but.html diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index f4617ac23..b9fff2ce0 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -43,6 +43,8 @@ You can determine your currently installed version using `pip freeze`: ### 3.6.5 * Fix `DjangoModelPermissions` to ensure user authentication before calling the view's `get_queryset()` method. As a side effect, this changes the order of the HTTP method permissions and authentication checks, and 405 responses will only be returned when authenticated. If you want to replicate the old behavior, see the PR for details. [#5376][gh5376] +* Deprecated `exclude_from_schema` on `APIView` and `api_view` decorator. Set `schema = None` or `@schema(None)` as appropriate. [#5422][gh5422] + ### 3.6.4 @@ -1423,3 +1425,4 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh5376]: https://github.com/encode/django-rest-framework/issues/5376 +[gh5422]: https://github.com/encode/django-rest-framework/issues/5422 diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 1297f96b4..cdbd59e99 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -9,6 +9,7 @@ used to annotate methods on viewsets that should be included by routers. from __future__ import unicode_literals import types +import warnings from django.utils import six @@ -75,7 +76,14 @@ def api_view(http_method_names=None, exclude_from_schema=False): WrappedAPIView.schema = getattr(func, 'schema', APIView.schema) - WrappedAPIView.exclude_from_schema = exclude_from_schema + if exclude_from_schema: + warnings.warn( + "The `exclude_from_schema` argument to `api_view` is pending deprecation. " + "Use the `schema` decorator instead, passing `None`.", + PendingDeprecationWarning + ) + WrappedAPIView.exclude_from_schema = exclude_from_schema + return WrappedAPIView.as_view() return decorator diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 01daa7e7d..3b5ef46d8 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -291,7 +291,7 @@ class APIRootView(views.APIView): The default basic root view for DefaultRouter """ _ignore_model_permissions = True - exclude_from_schema = True + schema = None # exclude from schema api_root_dict = None def get(self, request, *args, **kwargs): diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 8344f64f0..3e927527c 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -3,6 +3,7 @@ generators.py # Top-down schema generation See schemas.__init__.py for package overview. """ +import warnings from collections import OrderedDict from importlib import import_module @@ -148,6 +149,17 @@ class EndpointEnumerator(object): if not is_api_view(callback): return False # Ignore anything except REST framework views. + if hasattr(callback.cls, 'exclude_from_schema'): + fmt = ("The `{}.exclude_from_schema` attribute is pending deprecation. " + "Set `schema = None` instead.") + msg = fmt.format(callback.cls.__name__) + warnings.warn(msg, PendingDeprecationWarning) + if getattr(callback.cls, 'exclude_from_schema', False): + return False + + if callback.cls.schema is None: + return False + if path.endswith('.{format}') or path.endswith('.{format}/'): return False # Ignore .json style URLs. @@ -239,8 +251,6 @@ class SchemaGenerator(object): view_endpoints = [] for path, method, callback in self.endpoints: view = self.create_view(callback, method, request) - if getattr(view, 'exclude_from_schema', False): - continue path = self.coerce_path(path, method, view) paths.append(path) view_endpoints.append((path, method, view)) diff --git a/rest_framework/schemas/views.py b/rest_framework/schemas/views.py index 932b5a487..b13eadea9 100644 --- a/rest_framework/schemas/views.py +++ b/rest_framework/schemas/views.py @@ -11,7 +11,7 @@ from rest_framework.views import APIView class SchemaView(APIView): _ignore_model_permissions = True - exclude_from_schema = True + schema = None # exclude from schema renderer_classes = None schema_generator = None public = False diff --git a/rest_framework/views.py b/rest_framework/views.py index ccc2047ee..dfed15888 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -112,8 +112,6 @@ class APIView(View): # Allow dependency injection of other settings to make testing easier. settings = api_settings - # Mark the view as being included or excluded from schema generation. - exclude_from_schema = False schema = AutoSchema() @classmethod diff --git a/tests/test_schemas.py b/tests/test_schemas.py index f8a63aa89..184401a86 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -8,12 +8,15 @@ from django.test import TestCase, override_settings from rest_framework import filters, pagination, permissions, serializers from rest_framework.compat import coreapi, coreschema -from rest_framework.decorators import detail_route, list_route +from rest_framework.decorators import ( + api_view, detail_route, list_route, schema +) from rest_framework.request import Request from rest_framework.routers import DefaultRouter from rest_framework.schemas import ( AutoSchema, ManualSchema, SchemaGenerator, get_schema_view ) +from rest_framework.schemas.generators import EndpointEnumerator from rest_framework.test import APIClient, APIRequestFactory from rest_framework.utils import formatting from rest_framework.views import APIView @@ -613,3 +616,107 @@ def test_docstring_is_not_stripped_by_get_description(): descr = schema.get_description('example', 'get') # the first and last character are '\n' correctly removed by get_description assert descr == formatting.dedent(ExampleDocstringAPIView.__doc__[1:][:-1]) + + +# Views for SchemaGenerationExclusionTests +class ExcludedAPIView(APIView): + schema = None + + def get(self, request, *args, **kwargs): + pass + + +@api_view(['GET']) +@schema(None) +def excluded_fbv(request): + pass + + +@api_view(['GET']) +def included_fbv(request): + pass + + +@unittest.skipUnless(coreapi, 'coreapi is not installed') +class SchemaGenerationExclusionTests(TestCase): + def setUp(self): + self.patterns = [ + url('^excluded-cbv/$', ExcludedAPIView.as_view()), + url('^excluded-fbv/$', excluded_fbv), + url('^included-fbv/$', included_fbv), + ] + + def test_schema_generator_excludes_correctly(self): + """Schema should not include excluded views""" + generator = SchemaGenerator(title='Exclusions', patterns=self.patterns) + schema = generator.get_schema() + expected = coreapi.Document( + url='', + title='Exclusions', + content={ + 'included-fbv': { + 'list': coreapi.Link(url='/included-fbv/', action='get') + } + } + ) + + assert len(schema.data) == 1 + assert 'included-fbv' in schema.data + assert schema == expected + + def test_endpoint_enumerator_excludes_correctly(self): + """It is responsibility of EndpointEnumerator to exclude views""" + inspector = EndpointEnumerator(self.patterns) + endpoints = inspector.get_api_endpoints() + + assert len(endpoints) == 1 + path, method, callback = endpoints[0] + assert path == '/included-fbv/' + + def test_should_include_endpoint_excludes_correctly(self): + """This is the specific method that should handle the exclusion""" + inspector = EndpointEnumerator(self.patterns) + + # Not pretty. Mimics internals of EndpointEnumerator to put should_include_endpoint under test + pairs = [(inspector.get_path_from_regex(pattern.regex.pattern), pattern.callback) + for pattern in self.patterns] + + should_include = [ + inspector.should_include_endpoint(*pair) for pair in pairs + ] + + expected = [False, False, True] + + assert should_include == expected + + def test_deprecations(self): + with pytest.warns(PendingDeprecationWarning) as record: + @api_view(["GET"], exclude_from_schema=True) + def view(request): + pass + + assert len(record) == 1 + assert str(record[0].message) == ( + "The `exclude_from_schema` argument to `api_view` is pending " + "deprecation. Use the `schema` decorator instead, passing `None`." + ) + + class OldFashionedExcludedView(APIView): + exclude_from_schema = True + + def get(self, request, *args, **kwargs): + pass + + patterns = [ + url('^excluded-old-fashioned/$', OldFashionedExcludedView.as_view()), + ] + + inspector = EndpointEnumerator(patterns) + with pytest.warns(PendingDeprecationWarning) as record: + inspector.get_api_endpoints() + + assert len(record) == 1 + assert str(record[0].message) == ( + "The `OldFashionedExcludedView.exclude_from_schema` attribute is " + "pending deprecation. Set `schema = None` instead." + ) From c0a48622e150badb5440792d3e4b7cb3568a2147 Mon Sep 17 00:00:00 2001 From: Jeremy Nauta Date: Wed, 20 Sep 2017 03:33:50 -0600 Subject: [PATCH 081/217] Allow `ChoiceField.choices` to be set dynamically (#5426) ## Description The `choices` field for the `ChoiceField` class should be able to be edited after `ChoiceField.__init__` is called. ``` field = ChoiceField(choices=[1,2]) field.choices = [1] # Should no longer allow `2` as a choice ``` Currently, you must update `choices`, `grouped_choices`, and `choice_strings_to_values` to achieve this. This P/R keeps `grouped_choices` and `choice_strings_to_values` in sync whenever the `choices` are edited. --- rest_framework/fields.py | 26 +++++++++++++++++--------- tests/test_fields.py | 13 +++++++++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index d2079d5d6..63df452ce 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1337,18 +1337,10 @@ class ChoiceField(Field): html_cutoff_text = _('More than {count} items...') def __init__(self, choices, **kwargs): - self.grouped_choices = to_choices_dict(choices) - self.choices = flatten_choices_dict(self.grouped_choices) + self.choices = choices self.html_cutoff = kwargs.pop('html_cutoff', self.html_cutoff) self.html_cutoff_text = kwargs.pop('html_cutoff_text', self.html_cutoff_text) - # Map the string representation of choices to the underlying value. - # Allows us to deal with eg. integer choices while supporting either - # integer or string input, but still get the correct datatype out. - self.choice_strings_to_values = { - six.text_type(key): key for key in self.choices.keys() - } - self.allow_blank = kwargs.pop('allow_blank', False) super(ChoiceField, self).__init__(**kwargs) @@ -1377,6 +1369,22 @@ class ChoiceField(Field): cutoff_text=self.html_cutoff_text ) + def _get_choices(self): + return self._choices + + def _set_choices(self, choices): + self.grouped_choices = to_choices_dict(choices) + self._choices = flatten_choices_dict(self.grouped_choices) + + # Map the string representation of choices to the underlying value. + # Allows us to deal with eg. integer choices while supporting either + # integer or string input, but still get the correct datatype out. + self.choice_strings_to_values = { + six.text_type(key): key for key in self.choices.keys() + } + + choices = property(_get_choices, _set_choices) + class MultipleChoiceField(ChoiceField): default_error_messages = { diff --git a/tests/test_fields.py b/tests/test_fields.py index 4173e6ab5..011fbe7de 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1425,6 +1425,19 @@ class TestChoiceField(FieldValues): assert items[9].value == 'boolean' + def test_edit_choices(self): + field = serializers.ChoiceField( + allow_null=True, + choices=[ + 1, 2, + ] + ) + field.choices = [1] + assert field.run_validation(1) is 1 + with pytest.raises(serializers.ValidationError) as exc_info: + field.run_validation(2) + assert exc_info.value.detail == ['"2" is not a valid choice.'] + class TestChoiceFieldWithType(FieldValues): """ From 89daaf6276805fbe9aef7524130b1a917da15366 Mon Sep 17 00:00:00 2001 From: Xavier Ordoquy Date: Wed, 20 Sep 2017 12:05:04 +0200 Subject: [PATCH 082/217] Add the project layout to the quickstart to have a milestone for the project creation. (#5434) --- docs/tutorial/quickstart.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/tutorial/quickstart.md b/docs/tutorial/quickstart.md index e8a4c8ef6..31361413e 100644 --- a/docs/tutorial/quickstart.md +++ b/docs/tutorial/quickstart.md @@ -24,6 +24,30 @@ Create a new Django project named `tutorial`, then start a new app called `quick django-admin.py startapp quickstart cd .. +The project layout should look like: + + $ pwd + /tutorial + $ find . + . + ./manage.py + ./tutorial + ./tutorial/__init__.py + ./tutorial/quickstart + ./tutorial/quickstart/__init__.py + ./tutorial/quickstart/admin.py + ./tutorial/quickstart/apps.py + ./tutorial/quickstart/migrations + ./tutorial/quickstart/migrations/__init__.py + ./tutorial/quickstart/models.py + ./tutorial/quickstart/tests.py + ./tutorial/quickstart/views.py + ./tutorial/settings.py + ./tutorial/urls.py + ./tutorial/wsgi.py + +It may look unusual that the application has been created within the project directory. Using the project's namespace avoids name clashes with external module (topic goes outside the scope of the quickstart). + Now sync your database for the first time: python manage.py migrate From 7d6d043531845c8fdfbec7e62d1fe52ca04a0acf Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 20 Sep 2017 12:15:15 +0200 Subject: [PATCH 083/217] Fix DateTimeField TZ handling (#5435) * Add failing TZ tests for DateTimeField - tests "current" timezone activation - tests output for non-UTC timezones * Update DateTimeField TZ aware/naive test output * Fix DateTimeField TZ handling * Add Release Note for BC change --- docs/topics/release-notes.md | 7 +++ requirements/requirements-optionals.txt | 1 + rest_framework/fields.py | 7 ++- tests/test_fields.py | 60 +++++++++++++++++++++++-- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index b9fff2ce0..5744771b3 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -44,7 +44,11 @@ You can determine your currently installed version using `pip freeze`: * Fix `DjangoModelPermissions` to ensure user authentication before calling the view's `get_queryset()` method. As a side effect, this changes the order of the HTTP method permissions and authentication checks, and 405 responses will only be returned when authenticated. If you want to replicate the old behavior, see the PR for details. [#5376][gh5376] * Deprecated `exclude_from_schema` on `APIView` and `api_view` decorator. Set `schema = None` or `@schema(None)` as appropriate. [#5422][gh5422] +* Timezone-aware `DateTimeField`s now respect active or default) `timezone` during serialization, instead of always using UTC. + Resolves inconsistency whereby instances were serialised with supplied datetime for `create` but UTC for `retrieve`. [#3732][gh3732] + + **Possible backwards compatibility break** if you were relying on datetime strings being UTC. Have client interpret datetimes or [set default or active timezone (docs)][djangodocs-set-timezone] to UTC if needed. ### 3.6.4 @@ -1426,3 +1430,6 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh5376]: https://github.com/encode/django-rest-framework/issues/5376 [gh5422]: https://github.com/encode/django-rest-framework/issues/5422 +[gh5408]: https://github.com/encode/django-rest-framework/issues/5408 +[gh3732]: https://github.com/encode/django-rest-framework/issues/3732 +[djangodocs-set-timezone]: https://docs.djangoproject.com/en/1.11/topics/i18n/timezones/#default-time-zone-and-current-time-zone diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt index e8ba50851..319b7547a 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -1,4 +1,5 @@ # Optional packages which may be used with REST framework. +pytz==2017.2 markdown==2.6.4 django-guardian==1.4.8 django-filter==1.0.4 diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 63df452ce..072bbf1b9 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1125,7 +1125,9 @@ class DateTimeField(Field): """ field_timezone = getattr(self, 'timezone', self.default_timezone()) - if (field_timezone is not None) and not timezone.is_aware(value): + if field_timezone is not None: + if timezone.is_aware(value): + return value.astimezone(field_timezone) try: return timezone.make_aware(value, field_timezone) except InvalidTimeError: @@ -1135,7 +1137,7 @@ class DateTimeField(Field): return value def default_timezone(self): - return timezone.get_default_timezone() if settings.USE_TZ else None + return timezone.get_current_timezone() if settings.USE_TZ else None def to_internal_value(self, value): input_formats = getattr(self, 'input_formats', api_settings.DATETIME_INPUT_FORMATS) @@ -1174,6 +1176,7 @@ class DateTimeField(Field): return value if output_format.lower() == ISO_8601: + value = self.enforce_timezone(value) value = value.isoformat() if value.endswith('+00:00'): value = value[:-6] + 'Z' diff --git a/tests/test_fields.py b/tests/test_fields.py index 011fbe7de..c2b053189 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -10,12 +10,17 @@ import pytest from django.http import QueryDict from django.test import TestCase, override_settings from django.utils import six -from django.utils.timezone import utc +from django.utils.timezone import activate, deactivate, utc import rest_framework from rest_framework import compat, serializers from rest_framework.fields import is_simple_callable +try: + import pytz +except ImportError: + pytz = None + try: import typings except ImportError: @@ -1168,7 +1173,7 @@ class TestDateTimeField(FieldValues): datetime.date(2001, 1, 1): ['Expected a datetime but got a date.'], } outputs = { - datetime.datetime(2001, 1, 1, 13, 00): '2001-01-01T13:00:00', + datetime.datetime(2001, 1, 1, 13, 00): '2001-01-01T13:00:00Z', datetime.datetime(2001, 1, 1, 13, 00, tzinfo=utc): '2001-01-01T13:00:00Z', '2001-01-01T00:00:00': '2001-01-01T00:00:00', six.text_type('2016-01-10T00:00:00'): '2016-01-10T00:00:00', @@ -1230,10 +1235,59 @@ class TestNaiveDateTimeField(FieldValues): '2001-01-01 13:00': datetime.datetime(2001, 1, 1, 13, 00), } invalid_inputs = {} - outputs = {} + outputs = { + datetime.datetime(2001, 1, 1, 13, 00): '2001-01-01T13:00:00', + datetime.datetime(2001, 1, 1, 13, 00, tzinfo=utc): '2001-01-01T13:00:00', + } field = serializers.DateTimeField(default_timezone=None) +@pytest.mark.skipif(pytz is None, reason='pytz not installed') +class TestTZWithDateTimeField(FieldValues): + """ + Valid and invalid values for `DateTimeField` when not using UTC as the timezone. + """ + @classmethod + def setup_class(cls): + # use class setup method, as class-level attribute will still be evaluated even if test is skipped + kolkata = pytz.timezone('Asia/Kolkata') + + cls.valid_inputs = { + '2016-12-19T10:00:00': kolkata.localize(datetime.datetime(2016, 12, 19, 10)), + '2016-12-19T10:00:00+05:30': kolkata.localize(datetime.datetime(2016, 12, 19, 10)), + datetime.datetime(2016, 12, 19, 10): kolkata.localize(datetime.datetime(2016, 12, 19, 10)), + } + cls.invalid_inputs = {} + cls.outputs = { + datetime.datetime(2016, 12, 19, 10): '2016-12-19T10:00:00+05:30', + datetime.datetime(2016, 12, 19, 4, 30, tzinfo=utc): '2016-12-19T10:00:00+05:30', + } + cls.field = serializers.DateTimeField(default_timezone=kolkata) + + +@pytest.mark.skipif(pytz is None, reason='pytz not installed') +@override_settings(TIME_ZONE='UTC', USE_TZ=True) +class TestDefaultTZDateTimeField(TestCase): + """ + Test the current/default timezone handling in `DateTimeField`. + """ + + @classmethod + def setup_class(cls): + cls.field = serializers.DateTimeField() + cls.kolkata = pytz.timezone('Asia/Kolkata') + + def test_default_timezone(self): + assert self.field.default_timezone() == utc + + def test_current_timezone(self): + assert self.field.default_timezone() == utc + activate(self.kolkata) + assert self.field.default_timezone() == self.kolkata + deactivate() + assert self.field.default_timezone() == utc + + class TestNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues): """ Invalid values for `DateTimeField` with datetime in DST shift (non-existing or ambiguous) and timezone with DST. From cb6e7e0fdd3fe621926014d0a4612fc923c78ade Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 20 Sep 2017 14:23:34 +0200 Subject: [PATCH 084/217] Drop erroneous `)` in release notes --- docs/topics/release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 5744771b3..ef43df670 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -44,7 +44,7 @@ You can determine your currently installed version using `pip freeze`: * Fix `DjangoModelPermissions` to ensure user authentication before calling the view's `get_queryset()` method. As a side effect, this changes the order of the HTTP method permissions and authentication checks, and 405 responses will only be returned when authenticated. If you want to replicate the old behavior, see the PR for details. [#5376][gh5376] * Deprecated `exclude_from_schema` on `APIView` and `api_view` decorator. Set `schema = None` or `@schema(None)` as appropriate. [#5422][gh5422] -* Timezone-aware `DateTimeField`s now respect active or default) `timezone` during serialization, instead of always using UTC. +* Timezone-aware `DateTimeField`s now respect active or default `timezone` during serialization, instead of always using UTC. Resolves inconsistency whereby instances were serialised with supplied datetime for `create` but UTC for `retrieve`. [#3732][gh3732] From f6c19e5eacbdc8a132e996f66f019994f34fda70 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 14 Jul 2017 12:05:42 -0400 Subject: [PATCH 085/217] Remove DjangoFilterBackend and associated tests --- rest_framework/compat.py | 7 - rest_framework/filters.py | 41 +--- tests/models.py | 9 - tests/test_filters.py | 424 +------------------------------------- 4 files changed, 2 insertions(+), 479 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 168bccf83..528340d69 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -182,13 +182,6 @@ except ImportError: coreschema = None -# django-filter is optional -try: - import django_filters -except ImportError: - django_filters = None - - # django-crispy-forms is optional try: import crispy_forms diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 63ebf05ef..0473787bb 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -5,7 +5,6 @@ returned by list views. from __future__ import unicode_literals import operator -import warnings from functools import reduce from django.core.exceptions import ImproperlyConfigured @@ -18,7 +17,7 @@ from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ from rest_framework.compat import ( - coreapi, coreschema, distinct, django_filters, guardian, template_render + coreapi, coreschema, distinct, guardian, template_render ) from rest_framework.settings import api_settings @@ -40,44 +39,6 @@ class BaseFilterBackend(object): return [] -if django_filters: - from django_filters.rest_framework.filterset import FilterSet as DFFilterSet - - class FilterSet(DFFilterSet): - def __init__(self, *args, **kwargs): - warnings.warn( - "The built in 'rest_framework.filters.FilterSet' is deprecated. " - "You should use 'django_filters.rest_framework.FilterSet' instead.", - DeprecationWarning, stacklevel=2 - ) - return super(FilterSet, self).__init__(*args, **kwargs) - - DFBase = django_filters.rest_framework.DjangoFilterBackend - -else: - def FilterSet(): - assert False, 'django-filter must be installed to use the `FilterSet` class' - - DFBase = BaseFilterBackend - - -class DjangoFilterBackend(DFBase): - """ - A filter backend that uses django-filter. - """ - def __new__(cls, *args, **kwargs): - assert django_filters, 'Using DjangoFilterBackend, but django-filter is not installed' - assert django_filters.VERSION >= (0, 15, 3), 'django-filter 0.15.3 and above is required' - - warnings.warn( - "The built in 'rest_framework.filters.DjangoFilterBackend' is deprecated. " - "You should use 'django_filters.rest_framework.DjangoFilterBackend' instead.", - DeprecationWarning, stacklevel=2 - ) - - return super(DjangoFilterBackend, cls).__new__(cls, *args, **kwargs) - - class SearchFilter(BaseFilterBackend): # The URL query parameter used for the search. search_param = api_settings.SEARCH_PARAM diff --git a/tests/models.py b/tests/models.py index 6c9dde8fa..e5d49a0a5 100644 --- a/tests/models.py +++ b/tests/models.py @@ -24,15 +24,6 @@ class BasicModel(RESTFrameworkModel): ) -class BaseFilterableItem(RESTFrameworkModel): - text = models.CharField(max_length=100) - - -class FilterableItem(BaseFilterableItem): - decimal = models.DecimalField(max_digits=4, decimal_places=2) - date = models.DateField() - - # Models for relations tests # ManyToMany class ManyToManyTarget(RESTFrameworkModel): diff --git a/tests/test_filters.py b/tests/test_filters.py index 6df0a3169..dc5b18068 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -2,125 +2,21 @@ from __future__ import unicode_literals import datetime import unittest -import warnings -from decimal import Decimal import django import pytest -from django.conf.urls import url from django.core.exceptions import ImproperlyConfigured from django.db import models from django.test import TestCase from django.test.utils import override_settings -from django.utils.dateparse import parse_date from django.utils.six.moves import reload_module -from rest_framework import filters, generics, serializers, status -from rest_framework.compat import django_filters, reverse +from rest_framework import filters, generics, serializers from rest_framework.test import APIRequestFactory -from .models import BaseFilterableItem, BasicModel, FilterableItem - factory = APIRequestFactory() -if django_filters: - class FilterableItemSerializer(serializers.ModelSerializer): - class Meta: - model = FilterableItem - fields = '__all__' - - # Basic filter on a list view. - class FilterFieldsRootView(generics.ListCreateAPIView): - queryset = FilterableItem.objects.all() - serializer_class = FilterableItemSerializer - filter_fields = ['decimal', 'date'] - filter_backends = (filters.DjangoFilterBackend,) - - # These class are used to test a filter class. - class SeveralFieldsFilter(django_filters.FilterSet): - text = django_filters.CharFilter(lookup_expr='icontains') - decimal = django_filters.NumberFilter(lookup_expr='lt') - date = django_filters.DateFilter(lookup_expr='gt') - - class Meta: - model = FilterableItem - fields = ['text', 'decimal', 'date'] - - class FilterClassRootView(generics.ListCreateAPIView): - queryset = FilterableItem.objects.all() - serializer_class = FilterableItemSerializer - filter_class = SeveralFieldsFilter - filter_backends = (filters.DjangoFilterBackend,) - - # These classes are used to test a misconfigured filter class. - class MisconfiguredFilter(django_filters.FilterSet): - text = django_filters.CharFilter(lookup_expr='icontains') - - class Meta: - model = BasicModel - fields = ['text'] - - class IncorrectlyConfiguredRootView(generics.ListCreateAPIView): - queryset = FilterableItem.objects.all() - serializer_class = FilterableItemSerializer - filter_class = MisconfiguredFilter - filter_backends = (filters.DjangoFilterBackend,) - - class FilterClassDetailView(generics.RetrieveAPIView): - queryset = FilterableItem.objects.all() - serializer_class = FilterableItemSerializer - filter_class = SeveralFieldsFilter - filter_backends = (filters.DjangoFilterBackend,) - - # These classes are used to test base model filter support - class BaseFilterableItemFilter(django_filters.FilterSet): - text = django_filters.CharFilter() - - class Meta: - model = BaseFilterableItem - fields = '__all__' - - # Test the same filter using the deprecated internal FilterSet class. - class BaseFilterableItemFilterWithProxy(filters.FilterSet): - text = django_filters.CharFilter() - - class Meta: - model = BaseFilterableItem - fields = '__all__' - - class BaseFilterableItemFilterRootView(generics.ListCreateAPIView): - queryset = FilterableItem.objects.all() - serializer_class = FilterableItemSerializer - filter_class = BaseFilterableItemFilter - filter_backends = (filters.DjangoFilterBackend,) - - class BaseFilterableItemFilterWithProxyRootView(BaseFilterableItemFilterRootView): - filter_class = BaseFilterableItemFilterWithProxy - - # Regression test for #814 - class FilterFieldsQuerysetView(generics.ListCreateAPIView): - queryset = FilterableItem.objects.all() - serializer_class = FilterableItemSerializer - filter_fields = ['decimal', 'date'] - filter_backends = (filters.DjangoFilterBackend,) - - class GetQuerysetView(generics.ListCreateAPIView): - serializer_class = FilterableItemSerializer - filter_class = SeveralFieldsFilter - filter_backends = (filters.DjangoFilterBackend,) - - def get_queryset(self): - return FilterableItem.objects.all() - - urlpatterns = [ - url(r'^(?P\d+)/$', FilterClassDetailView.as_view(), name='detail-view'), - url(r'^$', FilterClassRootView.as_view(), name='root-view'), - url(r'^get-queryset/$', GetQuerysetView.as_view(), - name='get-queryset-view'), - ] - - class BaseFilterTests(TestCase): def setUp(self): self.original_coreapi = filters.coreapi @@ -142,288 +38,6 @@ class BaseFilterTests(TestCase): assert self.filter_backend.get_schema_fields({}) == [] -class CommonFilteringTestCase(TestCase): - def _serialize_object(self, obj): - return {'id': obj.id, 'text': obj.text, 'decimal': str(obj.decimal), 'date': obj.date.isoformat()} - - def setUp(self): - """ - Create 10 FilterableItem instances. - """ - base_data = ('a', Decimal('0.25'), datetime.date(2012, 10, 8)) - for i in range(10): - text = chr(i + ord(base_data[0])) * 3 # Produces string 'aaa', 'bbb', etc. - decimal = base_data[1] + i - date = base_data[2] - datetime.timedelta(days=i * 2) - FilterableItem(text=text, decimal=decimal, date=date).save() - - self.objects = FilterableItem.objects - self.data = [ - self._serialize_object(obj) - for obj in self.objects.all() - ] - - -class IntegrationTestFiltering(CommonFilteringTestCase): - """ - Integration tests for filtered list views. - """ - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_backend_deprecation(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - view = FilterFieldsRootView.as_view() - request = factory.get('/') - response = view(request).render() - - assert response.status_code == status.HTTP_200_OK - assert response.data == self.data - - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) - self.assertIn("'rest_framework.filters.DjangoFilterBackend' is deprecated.", str(w[-1].message)) - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_no_df_deprecation(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - - import django_filters.rest_framework - - class DFFilterFieldsRootView(FilterFieldsRootView): - filter_backends = (django_filters.rest_framework.DjangoFilterBackend,) - - view = DFFilterFieldsRootView.as_view() - request = factory.get('/') - response = view(request).render() - - assert response.status_code == status.HTTP_200_OK - assert response.data == self.data - assert len(w) == 0 - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_backend_mro(self): - class CustomBackend(filters.DjangoFilterBackend): - def filter_queryset(self, request, queryset, view): - assert False, "custom filter_queryset should run" - - class DFFilterFieldsRootView(FilterFieldsRootView): - filter_backends = (CustomBackend,) - - view = DFFilterFieldsRootView.as_view() - request = factory.get('/') - - with pytest.raises(AssertionError, message="custom filter_queryset should run"): - view(request).render() - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_get_filtered_fields_root_view(self): - """ - GET requests to paginated ListCreateAPIView should return paginated results. - """ - view = FilterFieldsRootView.as_view() - - # Basic test with no filter. - request = factory.get('/') - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - assert response.data == self.data - - # Tests that the decimal filter works. - search_decimal = Decimal('2.25') - request = factory.get('/', {'decimal': '%s' % search_decimal}) - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if Decimal(f['decimal']) == search_decimal] - assert response.data == expected_data - - # Tests that the date filter works. - search_date = datetime.date(2012, 9, 22) - request = factory.get('/', {'date': '%s' % search_date}) # search_date str: '2012-09-22' - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if parse_date(f['date']) == search_date] - assert response.data == expected_data - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_filter_with_queryset(self): - """ - Regression test for #814. - """ - view = FilterFieldsQuerysetView.as_view() - - # Tests that the decimal filter works. - search_decimal = Decimal('2.25') - request = factory.get('/', {'decimal': '%s' % search_decimal}) - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if Decimal(f['decimal']) == search_decimal] - assert response.data == expected_data - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_filter_with_get_queryset_only(self): - """ - Regression test for #834. - """ - view = GetQuerysetView.as_view() - request = factory.get('/get-queryset/') - view(request).render() - # Used to raise "issubclass() arg 2 must be a class or tuple of classes" - # here when neither `model' nor `queryset' was specified. - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_get_filtered_class_root_view(self): - """ - GET requests to filtered ListCreateAPIView that have a filter_class set - should return filtered results. - """ - view = FilterClassRootView.as_view() - - # Basic test with no filter. - request = factory.get('/') - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - assert response.data == self.data - - # Tests that the decimal filter set with 'lt' in the filter class works. - search_decimal = Decimal('4.25') - request = factory.get('/', {'decimal': '%s' % search_decimal}) - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if Decimal(f['decimal']) < search_decimal] - assert response.data == expected_data - - # Tests that the date filter set with 'gt' in the filter class works. - search_date = datetime.date(2012, 10, 2) - request = factory.get('/', {'date': '%s' % search_date}) # search_date str: '2012-10-02' - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if parse_date(f['date']) > search_date] - assert response.data == expected_data - - # Tests that the text filter set with 'icontains' in the filter class works. - search_text = 'ff' - request = factory.get('/', {'text': '%s' % search_text}) - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if search_text in f['text'].lower()] - assert response.data == expected_data - - # Tests that multiple filters works. - search_decimal = Decimal('5.25') - search_date = datetime.date(2012, 10, 2) - request = factory.get('/', { - 'decimal': '%s' % (search_decimal,), - 'date': '%s' % (search_date,) - }) - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - expected_data = [f for f in self.data if parse_date(f['date']) > search_date and - Decimal(f['decimal']) < search_decimal] - assert response.data == expected_data - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_incorrectly_configured_filter(self): - """ - An error should be displayed when the filter class is misconfigured. - """ - view = IncorrectlyConfiguredRootView.as_view() - - request = factory.get('/') - self.assertRaises(AssertionError, view, request) - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_base_model_filter(self): - """ - The `get_filter_class` model checks should allow base model filters. - """ - view = BaseFilterableItemFilterRootView.as_view() - - request = factory.get('/?text=aaa') - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - assert len(response.data) == 1 - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_base_model_filter_with_proxy(self): - """ - The `get_filter_class` model checks should allow base model filters. - """ - view = BaseFilterableItemFilterWithProxyRootView.as_view() - - request = factory.get('/?text=aaa') - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - assert len(response.data) == 1 - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_unknown_filter(self): - """ - GET requests with filters that aren't configured should return 200. - """ - view = FilterFieldsRootView.as_view() - - search_integer = 10 - request = factory.get('/', {'integer': '%s' % search_integer}) - response = view(request).render() - assert response.status_code == status.HTTP_200_OK - - -@override_settings(ROOT_URLCONF='tests.test_filters') -class IntegrationTestDetailFiltering(CommonFilteringTestCase): - """ - Integration tests for filtered detail views. - """ - def _get_url(self, item): - return reverse('detail-view', kwargs=dict(pk=item.pk)) - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_get_filtered_detail_view(self): - """ - GET requests to filtered RetrieveAPIView that have a filter_class set - should return filtered results. - """ - item = self.objects.all()[0] - data = self._serialize_object(item) - - # Basic test with no filter. - response = self.client.get(self._get_url(item)) - assert response.status_code == status.HTTP_200_OK - assert response.data == data - - # Tests that the decimal filter set that should fail. - search_decimal = Decimal('4.25') - high_item = self.objects.filter(decimal__gt=search_decimal)[0] - response = self.client.get( - '{url}'.format(url=self._get_url(high_item)), - {'decimal': '{param}'.format(param=search_decimal)}) - assert response.status_code == status.HTTP_404_NOT_FOUND - - # Tests that the decimal filter set that should succeed. - search_decimal = Decimal('4.25') - low_item = self.objects.filter(decimal__lt=search_decimal)[0] - low_item_data = self._serialize_object(low_item) - response = self.client.get( - '{url}'.format(url=self._get_url(low_item)), - {'decimal': '{param}'.format(param=search_decimal)}) - assert response.status_code == status.HTTP_200_OK - assert response.data == low_item_data - - # Tests that multiple filters works. - search_decimal = Decimal('5.25') - search_date = datetime.date(2012, 10, 2) - valid_item = self.objects.filter(decimal__lt=search_decimal, date__gt=search_date)[0] - valid_item_data = self._serialize_object(valid_item) - response = self.client.get( - '{url}'.format(url=self._get_url(valid_item)), { - 'decimal': '{decimal}'.format(decimal=search_decimal), - 'date': '{date}'.format(date=search_date) - }) - assert response.status_code == status.HTTP_200_OK - assert response.data == valid_item_data - - class SearchFilterModel(models.Model): title = models.CharField(max_length=20) text = models.CharField(max_length=100) @@ -720,42 +334,6 @@ class DjangoFilterOrderingSerializer(serializers.ModelSerializer): fields = '__all__' -class DjangoFilterOrderingTests(TestCase): - def setUp(self): - data = [{ - 'date': datetime.date(2012, 10, 8), - 'text': 'abc' - }, { - 'date': datetime.date(2013, 10, 8), - 'text': 'bcd' - }, { - 'date': datetime.date(2014, 10, 8), - 'text': 'cde' - }] - - for d in data: - DjangoFilterOrderingModel.objects.create(**d) - - @unittest.skipUnless(django_filters, 'django-filter not installed') - def test_default_ordering(self): - class DjangoFilterOrderingView(generics.ListAPIView): - serializer_class = DjangoFilterOrderingSerializer - queryset = DjangoFilterOrderingModel.objects.all() - filter_backends = (filters.DjangoFilterBackend,) - filter_fields = ['text'] - ordering = ('-date',) - - view = DjangoFilterOrderingView.as_view() - request = factory.get('/') - response = view(request) - - assert response.data == [ - {'id': 3, 'date': '2014-10-08', 'text': 'cde'}, - {'id': 2, 'date': '2013-10-08', 'text': 'bcd'}, - {'id': 1, 'date': '2012-10-08', 'text': 'abc'} - ] - - class OrderingFilterTests(TestCase): def setUp(self): # Sequence of title/text is: From b64f8066c06c3ad65e07e6741d8d7266d81ceba9 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 7 Jul 2017 12:46:17 -0400 Subject: [PATCH 086/217] Add json util wrapper, failing JSONField test --- rest_framework/utils/encoders.py | 2 +- rest_framework/utils/json.py | 33 ++++++++++++++++++++++++++++++++ tests/test_fields.py | 1 + tests/test_utils.py | 21 ++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 rest_framework/utils/json.py diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 8896e4f2c..a4fe8d0c4 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -1,7 +1,7 @@ """ Helper classes for parsers. """ -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import datetime import decimal diff --git a/rest_framework/utils/json.py b/rest_framework/utils/json.py new file mode 100644 index 000000000..cc7df542e --- /dev/null +++ b/rest_framework/utils/json.py @@ -0,0 +1,33 @@ + +from __future__ import absolute_import + +import functools +import json + + +def strict_constant(o): + raise ValueError('Out of range float values are not JSON compliant: ' + repr(o)) + + +@functools.wraps(json.dump) +def dump(*args, **kwargs): + kwargs.setdefault('allow_nan', False) + return json.dump(*args, **kwargs) + + +@functools.wraps(json.dumps) +def dumps(*args, **kwargs): + kwargs.setdefault('allow_nan', False) + return json.dumps(*args, **kwargs) + + +@functools.wraps(json.load) +def load(*args, **kwargs): + kwargs.setdefault('parse_constant', strict_constant) + return json.load(*args, **kwargs) + + +@functools.wraps(json.loads) +def loads(*args, **kwargs): + kwargs.setdefault('parse_constant', strict_constant) + return json.loads(*args, **kwargs) diff --git a/tests/test_fields.py b/tests/test_fields.py index c2b053189..c1b99818a 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1896,6 +1896,7 @@ class TestJSONField(FieldValues): ] invalid_inputs = [ ({'a': set()}, ['Value must be valid JSON.']), + ({'a': float('inf')}, ['Value must be valid JSON.']), ] outputs = [ ({ diff --git a/tests/test_utils.py b/tests/test_utils.py index 11c9e9bb0..9619776d6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -9,6 +9,7 @@ import rest_framework.utils.model_meta from rest_framework.compat import _resolve_model from rest_framework.routers import SimpleRouter from rest_framework.serializers import ModelSerializer +from rest_framework.utils import json from rest_framework.utils.breadcrumbs import get_breadcrumbs from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet @@ -177,3 +178,23 @@ class ResolveModelWithPatchedDjangoTests(TestCase): def test_blows_up_if_model_does_not_resolve(self): with self.assertRaises(ImproperlyConfigured): _resolve_model('tests.BasicModel') + + +class JsonFloatTests(TestCase): + """ + Internaly, wrapped json functions should adhere to strict float handling + """ + + def test_dumps(self): + with self.assertRaises(ValueError): + json.dumps(float('inf')) + + with self.assertRaises(ValueError): + json.dumps(float('nan')) + + def test_loads(self): + with self.assertRaises(ValueError): + json.loads("Infinity") + + with self.assertRaises(ValueError): + json.loads("NaN") From d740bae95a30d473e9de0019bc31475900caa435 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 7 Jul 2017 12:47:08 -0400 Subject: [PATCH 087/217] Update json imports --- rest_framework/fields.py | 3 +-- rest_framework/parsers.py | 2 +- rest_framework/renderers.py | 3 +-- rest_framework/utils/serializer_helpers.py | 2 +- tests/test_renderers.py | 2 +- tests/test_routers.py | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 072bbf1b9..e17a0bf9a 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -5,7 +5,6 @@ import copy import datetime import decimal import inspect -import json import re import uuid from collections import OrderedDict @@ -37,7 +36,7 @@ from rest_framework.compat import ( ) from rest_framework.exceptions import ErrorDetail, ValidationError from rest_framework.settings import api_settings -from rest_framework.utils import html, humanize_datetime, representation +from rest_framework.utils import html, humanize_datetime, json, representation class empty: diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index 0e40e1a7a..5ebaeca2e 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -7,7 +7,6 @@ on the request, such as form content or json encoded data. from __future__ import unicode_literals import codecs -import json from django.conf import settings from django.core.files.uploadhandler import StopFutureHandlers @@ -23,6 +22,7 @@ from django.utils.six.moves.urllib import parse as urlparse from rest_framework import renderers from rest_framework.exceptions import ParseError +from rest_framework.utils import json class DataAndFiles(object): diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 687cb0e1e..a87eb1889 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -9,7 +9,6 @@ REST framework also provides an HTML renderer that renders the browsable API. from __future__ import unicode_literals import base64 -import json from collections import OrderedDict from django import forms @@ -30,7 +29,7 @@ from rest_framework.compat import ( from rest_framework.exceptions import ParseError from rest_framework.request import is_form_media_type, override_method from rest_framework.settings import api_settings -from rest_framework.utils import encoders +from rest_framework.utils import encoders, json from rest_framework.utils.breadcrumbs import get_breadcrumbs from rest_framework.utils.field_mapping import ClassLookupDict diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index d1bba9666..da89d08ff 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -1,12 +1,12 @@ from __future__ import unicode_literals import collections -import json from collections import OrderedDict from django.utils.encoding import force_text from rest_framework.compat import unicode_to_repr +from rest_framework.utils import json class ReturnDict(OrderedDict): diff --git a/tests/test_renderers.py b/tests/test_renderers.py index 1625b0b70..ccc910c63 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import json import re from collections import MutableMapping, OrderedDict @@ -24,6 +23,7 @@ from rest_framework.request import Request from rest_framework.response import Response from rest_framework.settings import api_settings from rest_framework.test import APIRequestFactory +from rest_framework.utils import json from rest_framework.views import APIView DUMMYSTATUS = status.HTTP_200_OK diff --git a/tests/test_routers.py b/tests/test_routers.py index fee39b2b3..cbc7c0554 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import json from collections import namedtuple import pytest @@ -15,6 +14,7 @@ from rest_framework.decorators import detail_route, list_route from rest_framework.response import Response from rest_framework.routers import DefaultRouter, SimpleRouter from rest_framework.test import APIRequestFactory +from rest_framework.utils import json factory = APIRequestFactory() From 8ab75a2f01df89ae14b21f44d3f76015e9191969 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 10 Jul 2017 15:23:12 -0400 Subject: [PATCH 088/217] Add 'STRICT_JSON' API setting. STRICT_JSON controls the renderer & parser behavior on whether or not to accept non-standard float values (NaN, Infinity). --- rest_framework/parsers.py | 5 ++++- rest_framework/renderers.py | 3 ++- rest_framework/settings.py | 1 + tests/test_parsers.py | 24 +++++++++++++++++++++--- tests/test_renderers.py | 13 +++++++++++++ tests/test_utils.py | 7 +++++++ 6 files changed, 48 insertions(+), 5 deletions(-) diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index 5ebaeca2e..7a256276a 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -22,6 +22,7 @@ from django.utils.six.moves.urllib import parse as urlparse from rest_framework import renderers from rest_framework.exceptions import ParseError +from rest_framework.settings import api_settings from rest_framework.utils import json @@ -53,6 +54,7 @@ class JSONParser(BaseParser): """ media_type = 'application/json' renderer_class = renderers.JSONRenderer + strict = api_settings.STRICT_JSON def parse(self, stream, media_type=None, parser_context=None): """ @@ -63,7 +65,8 @@ class JSONParser(BaseParser): try: decoded_stream = codecs.getreader(encoding)(stream) - return json.load(decoded_stream) + parse_constant = json.strict_constant if self.strict else None + return json.load(decoded_stream, parse_constant=parse_constant) except ValueError as exc: raise ParseError('JSON parse error - %s' % six.text_type(exc)) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index a87eb1889..90f516b35 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -61,6 +61,7 @@ class JSONRenderer(BaseRenderer): encoder_class = encoders.JSONEncoder ensure_ascii = not api_settings.UNICODE_JSON compact = api_settings.COMPACT_JSON + strict = api_settings.STRICT_JSON # We don't set a charset because JSON is a binary encoding, # that can be encoded as utf-8, utf-16 or utf-32. @@ -101,7 +102,7 @@ class JSONRenderer(BaseRenderer): ret = json.dumps( data, cls=self.encoder_class, indent=indent, ensure_ascii=self.ensure_ascii, - separators=separators + allow_nan=not self.strict, separators=separators ) # On python 2.x json.dumps() returns bytestrings if ensure_ascii=True, diff --git a/rest_framework/settings.py b/rest_framework/settings.py index 3f3c9110a..bc42c38a6 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -110,6 +110,7 @@ DEFAULTS = { # Encoding 'UNICODE_JSON': True, 'COMPACT_JSON': True, + 'STRICT_JSON': True, 'COERCE_DECIMAL_TO_STRING': True, 'UPLOADED_FILES_USE_URL': True, diff --git a/tests/test_parsers.py b/tests/test_parsers.py index 2499bfa3a..0a18aad1a 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- - from __future__ import unicode_literals +import math + import pytest from django import forms from django.core.files.uploadhandler import ( @@ -9,7 +10,7 @@ from django.core.files.uploadhandler import ( ) from django.http.request import RawPostDataException from django.test import TestCase -from django.utils.six.moves import StringIO +from django.utils.six import BytesIO, StringIO from rest_framework.exceptions import ParseError from rest_framework.parsers import ( @@ -42,7 +43,6 @@ class TestFileUploadParser(TestCase): def setUp(self): class MockRequest(object): pass - from io import BytesIO self.stream = BytesIO( "Test text file".encode('utf-8') ) @@ -129,6 +129,24 @@ class TestFileUploadParser(TestCase): self.parser_context['request'].META['HTTP_CONTENT_DISPOSITION'] = disposition +class TestJSONParser(TestCase): + def bytes(self, value): + return BytesIO(value.encode('utf-8')) + + def test_float_strictness(self): + parser = JSONParser() + + # Default to strict + for value in ['Infinity', '-Infinity', 'NaN']: + with pytest.raises(ParseError): + parser.parse(self.bytes(value)) + + parser.strict = False + assert parser.parse(self.bytes('Infinity')) == float('inf') + assert parser.parse(self.bytes('-Infinity')) == float('-inf') + assert math.isnan(parser.parse(self.bytes('NaN'))) + + class TestPOSTAccessed(TestCase): def setUp(self): self.factory = APIRequestFactory() diff --git a/tests/test_renderers.py b/tests/test_renderers.py index ccc910c63..5f4aa51a3 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -358,6 +358,19 @@ class JSONRendererTests(TestCase): with self.assertRaises(TypeError): JSONRenderer().render(x) + def test_float_strictness(self): + renderer = JSONRenderer() + + # Default to strict + for value in [float('inf'), float('-inf'), float('nan')]: + with pytest.raises(ValueError): + renderer.render(value) + + renderer.strict = False + assert renderer.render(float('inf')) == b'Infinity' + assert renderer.render(float('-inf')) == b'-Infinity' + assert renderer.render(float('nan')) == b'NaN' + def test_without_content_type_args(self): """ Test basic JSON rendering. diff --git a/tests/test_utils.py b/tests/test_utils.py index 9619776d6..c5e6f26dc 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -198,3 +198,10 @@ class JsonFloatTests(TestCase): with self.assertRaises(ValueError): json.loads("NaN") + + +@override_settings(STRICT_JSON=False) +class NonStrictJsonFloatTests(JsonFloatTests): + """ + 'STRICT_JSON = False' should not somehow affect internal json behavior + """ From 901657e7e8fe460cf9f14b48b9bce70d3cd06b09 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 10 Jul 2017 17:22:55 -0400 Subject: [PATCH 089/217] Add banned imports to prevent standard json import --- requirements/requirements-codestyle.txt | 1 + rest_framework/utils/encoders.py | 2 +- rest_framework/utils/json.py | 2 +- setup.cfg | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements/requirements-codestyle.txt b/requirements/requirements-codestyle.txt index 264416f5f..9bafbe391 100644 --- a/requirements/requirements-codestyle.txt +++ b/requirements/requirements-codestyle.txt @@ -1,5 +1,6 @@ # PEP8 code linting, which we run on all commits. flake8==2.4.0 +flake8-tidy-imports==1.1.0 pep8==1.5.7 # Sort and lint imports diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index a4fe8d0c4..d754e4465 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, unicode_literals import datetime import decimal -import json +import json # noqa import uuid from django.db.models.query import QuerySet diff --git a/rest_framework/utils/json.py b/rest_framework/utils/json.py index cc7df542e..ea5e22725 100644 --- a/rest_framework/utils/json.py +++ b/rest_framework/utils/json.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import functools -import json +import json # noqa def strict_constant(o): diff --git a/setup.cfg b/setup.cfg index 509abd58b..9f6b5be77 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,3 +6,4 @@ license_file = LICENSE.md [flake8] ignore = E501 +banned-modules = json = use from rest_framework.utils import json! From c98223f2316984ac362ba06bc82d3e2ca454ede3 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 10 Jul 2017 18:51:44 -0400 Subject: [PATCH 090/217] Pass on invalid value (Inf, NaN) encoding in JSONBoundField --- rest_framework/utils/serializer_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index da89d08ff..fa79b6526 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -88,7 +88,7 @@ class JSONBoundField(BoundField): value = self.value try: value = json.dumps(self.value, sort_keys=True, indent=4) - except TypeError: + except (TypeError, ValueError): pass return self.__class__(self._field, value, self.errors, self._prefix) From 215248c0421f451c2b6e64c45f511da7e60eae78 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 10 Jul 2017 19:34:04 -0400 Subject: [PATCH 091/217] Add 'STRICT_JSON' docs --- docs/api-guide/settings.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index aaedd463e..5c9eaa12c 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -362,6 +362,14 @@ The default style is to return minified responses, in line with [Heroku's API de Default: `True` +#### STRICT_JSON + +When set to `True`, JSON rendering and parsing will only observe syntactically valid JSON, raising an exception for the extended float values (`nan`, `inf`, `-inf`) accepted by Python's `json` module. This is the recommended setting, as these values are not generally supported. e.g., neither Javascript's `JSON.Parse` nor PostgreSQL's JSON data type accept these values. + +When set to `False`, JSON rendering and parsing will be permissive. However, these values are still invalid and will need to be specially handled in your code. + +Default: `True` + #### COERCE_DECIMAL_TO_STRING When returning decimal objects in API representations that do not support a native decimal type, it is normally best to return the value as a string. This avoids the loss of precision that occurs with binary floating point implementations. From ea894cd90a7544b0507c5f94bb3eb3da25000ccf Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Tue, 11 Jul 2017 11:53:20 -0400 Subject: [PATCH 092/217] Add docstring to json wrapper module --- rest_framework/utils/json.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rest_framework/utils/json.py b/rest_framework/utils/json.py index ea5e22725..cb5572380 100644 --- a/rest_framework/utils/json.py +++ b/rest_framework/utils/json.py @@ -1,3 +1,10 @@ +""" +Wrapper for the builtin json module that ensures compliance with the JSON spec. + +REST framework should always import this wrapper module in order to maintain +spec-compliant encoding/decoding. Support for non-standard features should be +handled by users at the renderer and parser layer. +""" from __future__ import absolute_import From e29ad1e7b386f6a2f46b1e67560cdb93bdc050bf Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Fri, 22 Sep 2017 12:03:05 +0200 Subject: [PATCH 093/217] =?UTF-8?q?JSONEncoder:=20Don=E2=80=99t=20strip=20?= =?UTF-8?q?microseconds=20from=20`time`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4749. This is the matching commit to the fix for `datetime` in #4256 --- rest_framework/utils/encoders.py | 2 -- tests/test_encoders.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index d754e4465..87df365e0 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -37,8 +37,6 @@ class JSONEncoder(json.JSONEncoder): if timezone and timezone.is_aware(obj): raise ValueError("JSON can't represent timezone-aware times.") representation = obj.isoformat() - if obj.microsecond: - representation = representation[:12] return representation elif isinstance(obj, datetime.timedelta): return six.text_type(total_seconds(obj)) diff --git a/tests/test_encoders.py b/tests/test_encoders.py index 8f8694c47..27136df87 100644 --- a/tests/test_encoders.py +++ b/tests/test_encoders.py @@ -44,7 +44,7 @@ class JSONEncoderTests(TestCase): Tests encoding a timezone """ current_time = datetime.now().time() - assert self.encoder.default(current_time) == current_time.isoformat()[:12] + assert self.encoder.default(current_time) == current_time.isoformat() def test_encode_time_tz(self): """ From aecca9d8e83ed42cf6d4b04de84d82dd185e2aa7 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 25 Sep 2017 11:04:23 +0200 Subject: [PATCH 094/217] Add note on force_authenticate + refresh_from_db MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …in case you’re reusing the same in-memory user whilst updating it in the DB. Closes #5016, closes #5066, closes #4102 --- docs/api-guide/testing.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/api-guide/testing.md b/docs/api-guide/testing.md index 2b93080b3..caba5cea2 100644 --- a/docs/api-guide/testing.md +++ b/docs/api-guide/testing.md @@ -86,6 +86,10 @@ For example, when forcibly authenticating using a token, you might do something --- +**Note**: `force_authenticate` directly sets `request.user` to the in-memory `user` instance. If you are re-using the same `user` instance across multiple tests that update the saved `user` state, you may need to call [`refresh_from_db()`][refresh_from_db_docs] between tests. + +--- + **Note**: When using `APIRequestFactory`, the object that is returned is Django's standard `HttpRequest`, and not REST framework's `Request` object, which is only generated once the view is called. This means that setting attributes directly on the request object may not always have the effect you expect. For example, setting `.token` directly will have no effect, and setting `.user` directly will only work if session authentication is being used. @@ -378,3 +382,4 @@ For example, to add support for using `format='html'` in test requests, you migh [client]: https://docs.djangoproject.com/en/stable/topics/testing/tools/#the-test-client [requestfactory]: https://docs.djangoproject.com/en/stable/topics/testing/advanced/#django.test.client.RequestFactory [configuration]: #configuration +[refresh_from_db_docs]: https://docs.djangoproject.com/en/1.11/ref/models/instances/#django.db.models.Model.refresh_from_db From 60b9e58a1241a8821c7020555104b365cd97a1ec Mon Sep 17 00:00:00 2001 From: Kris Dorosz Date: Wed, 5 Jul 2017 10:35:17 +0200 Subject: [PATCH 095/217] Add support for page_size parameter in CursorPaginator class --- rest_framework/pagination.py | 34 +++++++- tests/test_pagination.py | 162 +++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py index 61e0a80b0..2c3b0d2a5 100644 --- a/rest_framework/pagination.py +++ b/rest_framework/pagination.py @@ -482,6 +482,15 @@ class CursorPagination(BasePagination): ordering = '-created' template = 'rest_framework/pagination/previous_and_next.html' + # Client can control the page size using this query parameter. + # Default is 'None'. Set to eg 'page_size' to enable usage. + page_size_query_param = None + page_size_query_description = _('Number of results to return per page.') + + # Set to an integer to limit the maximum page size the client may request. + # Only relevant if 'page_size_query_param' has also been set. + max_page_size = None + # The offset in the cursor is used in situations where we have a # nearly-unique index. (Eg millisecond precision creation timestamps) # We guard against malicious users attempting to cause expensive database @@ -566,6 +575,16 @@ class CursorPagination(BasePagination): return self.page def get_page_size(self, request): + if self.page_size_query_param: + try: + return _positive_int( + request.query_params[self.page_size_query_param], + strict=True, + cutoff=self.max_page_size + ) + except (KeyError, ValueError): + pass + return self.page_size def get_next_link(self): @@ -779,7 +798,7 @@ class CursorPagination(BasePagination): def get_schema_fields(self, view): assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`' assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`' - return [ + fields = [ coreapi.Field( name=self.cursor_query_param, required=False, @@ -790,3 +809,16 @@ class CursorPagination(BasePagination): ) ) ] + if self.page_size_query_param is not None: + fields.append( + coreapi.Field( + name=self.page_size_query_param, + required=False, + location='query', + schema=coreschema.Integer( + title='Page size', + description=force_text(self.page_size_query_description) + ) + ) + ) + return fields diff --git a/tests/test_pagination.py b/tests/test_pagination.py index dd7f70330..d9ad9e6f6 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -633,6 +633,164 @@ class CursorPaginationTestsMixin: assert isinstance(self.pagination.to_html(), type('')) + def test_cursor_pagination_with_page_size(self): + (previous, current, next, previous_url, next_url) = self.get_pages('/?page_size=20') + + assert previous is None + assert current == [1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 7, 7, 7, 7, 7] + assert next == [7, 7, 7, 8, 9, 9, 9, 9, 9, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + assert previous == [1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 7, 7, 7, 7, 7] + assert current == [7, 7, 7, 8, 9, 9, 9, 9, 9, 9] + assert next is None + + def test_cursor_pagination_with_page_size_over_limit(self): + (previous, current, next, previous_url, next_url) = self.get_pages('/?page_size=30') + + assert previous is None + assert current == [1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 7, 7, 7, 7, 7] + assert next == [7, 7, 7, 8, 9, 9, 9, 9, 9, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + assert previous == [1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 4, 4, 5, 6, 7, 7, 7, 7, 7, 7] + assert current == [7, 7, 7, 8, 9, 9, 9, 9, 9, 9] + assert next is None + + def test_cursor_pagination_with_page_size_zero(self): + (previous, current, next, previous_url, next_url) = self.get_pages('/?page_size=0') + + assert previous is None + assert current == [1, 1, 1, 1, 1] + assert next == [1, 2, 3, 4, 4] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [1, 1, 1, 1, 1] + assert current == [1, 2, 3, 4, 4] + assert next == [4, 4, 5, 6, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [1, 2, 3, 4, 4] + assert current == [4, 4, 5, 6, 7] + assert next == [7, 7, 7, 7, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [4, 4, 4, 5, 6] # Paging artifact + assert current == [7, 7, 7, 7, 7] + assert next == [7, 7, 7, 8, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [7, 7, 7, 7, 7] + assert current == [7, 7, 7, 8, 9] + assert next == [9, 9, 9, 9, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [7, 7, 7, 8, 9] + assert current == [9, 9, 9, 9, 9] + assert next is None + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [7, 7, 7, 7, 7] + assert current == [7, 7, 7, 8, 9] + assert next == [9, 9, 9, 9, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [4, 4, 5, 6, 7] + assert current == [7, 7, 7, 7, 7] + assert next == [8, 9, 9, 9, 9] # Paging artifact + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [1, 2, 3, 4, 4] + assert current == [4, 4, 5, 6, 7] + assert next == [7, 7, 7, 7, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [1, 1, 1, 1, 1] + assert current == [1, 2, 3, 4, 4] + assert next == [4, 4, 5, 6, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous is None + assert current == [1, 1, 1, 1, 1] + assert next == [1, 2, 3, 4, 4] + + def test_cursor_pagination_with_page_size_negative(self): + (previous, current, next, previous_url, next_url) = self.get_pages('/?page_size=-5') + + assert previous is None + assert current == [1, 1, 1, 1, 1] + assert next == [1, 2, 3, 4, 4] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [1, 1, 1, 1, 1] + assert current == [1, 2, 3, 4, 4] + assert next == [4, 4, 5, 6, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [1, 2, 3, 4, 4] + assert current == [4, 4, 5, 6, 7] + assert next == [7, 7, 7, 7, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [4, 4, 4, 5, 6] # Paging artifact + assert current == [7, 7, 7, 7, 7] + assert next == [7, 7, 7, 8, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [7, 7, 7, 7, 7] + assert current == [7, 7, 7, 8, 9] + assert next == [9, 9, 9, 9, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(next_url) + + assert previous == [7, 7, 7, 8, 9] + assert current == [9, 9, 9, 9, 9] + assert next is None + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [7, 7, 7, 7, 7] + assert current == [7, 7, 7, 8, 9] + assert next == [9, 9, 9, 9, 9] + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [4, 4, 5, 6, 7] + assert current == [7, 7, 7, 7, 7] + assert next == [8, 9, 9, 9, 9] # Paging artifact + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [1, 2, 3, 4, 4] + assert current == [4, 4, 5, 6, 7] + assert next == [7, 7, 7, 7, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous == [1, 1, 1, 1, 1] + assert current == [1, 2, 3, 4, 4] + assert next == [4, 4, 5, 6, 7] + + (previous, current, next, previous_url, next_url) = self.get_pages(previous_url) + + assert previous is None + assert current == [1, 1, 1, 1, 1] + assert next == [1, 2, 3, 4, 4] + class TestCursorPagination(CursorPaginationTestsMixin): """ @@ -671,6 +829,8 @@ class TestCursorPagination(CursorPaginationTestsMixin): class ExamplePagination(pagination.CursorPagination): page_size = 5 + page_size_query_param = 'page_size' + max_page_size = 20 ordering = 'created' self.pagination = ExamplePagination() @@ -727,6 +887,8 @@ class TestCursorPaginationWithValueQueryset(CursorPaginationTestsMixin, TestCase def setUp(self): class ExamplePagination(pagination.CursorPagination): page_size = 5 + page_size_query_param = 'page_size' + max_page_size = 20 ordering = 'created' self.pagination = ExamplePagination() From 11e585119691d851a6c206a38a07c6dafe8038a2 Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Mon, 17 Jul 2017 12:02:30 +0200 Subject: [PATCH 096/217] Update pagination.md Fixed 2 missing spaces in Custom Pagination snippet --- docs/api-guide/pagination.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index d767e45de..496886473 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -226,8 +226,8 @@ Suppose we want to replace the default pagination output style with a modified f def get_paginated_response(self, data): return Response({ 'links': { - 'next': self.get_next_link(), - 'previous': self.get_previous_link() + 'next': self.get_next_link(), + 'previous': self.get_previous_link() }, 'count': self.page.paginator.count, 'results': data From 107e8b3d23a933b8cdc1f14045d7d42742be53a9 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 25 Sep 2017 09:36:31 -0400 Subject: [PATCH 097/217] Make `DEFAULT_PAGINATION_CLASS` `None` by default. (#5170) * Changes to the paginator defaults and settings Require a default paginator be specified when using the page size setting. https://github.com/encode/django-rest-framework/issues/5168 * DRF-5168 import warnings missed this in last commit * Add a system checks file Add a check for pagination settings for the 3.7 upgrade cycle. * more compatible import approach * missing bactic * revised language and approach to import the system check Adds a rest framework app config. * Adjust doc wording --- docs/api-guide/pagination.md | 6 +++--- rest_framework/__init__.py | 2 ++ rest_framework/apps.py | 10 ++++++++++ rest_framework/checks.py | 18 ++++++++++++++++++ rest_framework/settings.py | 2 +- 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 rest_framework/apps.py create mode 100644 rest_framework/checks.py diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index 496886473..7b5e5b3f6 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -21,14 +21,14 @@ Pagination can be turned off by setting the pagination class to `None`. ## Setting the pagination style -The default pagination style may be set globally, using the `DEFAULT_PAGINATION_CLASS` and `PAGE_SIZE` setting keys. For example, to use the built-in limit/offset pagination, you would do something like this: +The pagination style may be set globally, using the `DEFAULT_PAGINATION_CLASS` and `PAGE_SIZE` setting keys. For example, to use the built-in limit/offset pagination, you would do something like this: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 100 } -Note that you need to set both the pagination class, and the page size that should be used. +Note that you need to set both the pagination class, and the page size that should be used. Both `DEFAULT_PAGINATION_CLASS` and `PAGE_SIZE` are `None` by default. You can also set the pagination class on an individual view by using the `pagination_class` attribute. Typically you'll want to use the same pagination style throughout your API, although you might want to vary individual aspects of the pagination, such as default or maximum page size, on a per-view basis. @@ -85,7 +85,7 @@ This pagination style accepts a single number page number in the request query p #### Setup -To enable the `PageNumberPagination` style globally, use the following configuration, modifying the `PAGE_SIZE` as desired: +To enable the `PageNumberPagination` style globally, use the following configuration, and set the `PAGE_SIZE` as desired: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py index 9da9989e9..ae130a4d4 100644 --- a/rest_framework/__init__.py +++ b/rest_framework/__init__.py @@ -21,3 +21,5 @@ HTTP_HEADER_ENCODING = 'iso-8859-1' # Default datetime input and output formats ISO_8601 = 'iso-8601' + +default_app_config = 'rest_framework.apps.RestFrameworkConfig' diff --git a/rest_framework/apps.py b/rest_framework/apps.py new file mode 100644 index 000000000..f6013eb7e --- /dev/null +++ b/rest_framework/apps.py @@ -0,0 +1,10 @@ +from django.apps import AppConfig + + +class RestFrameworkConfig(AppConfig): + name = 'rest_framework' + verbose_name = "Django REST framework" + + def ready(self): + # Add System checks + from .checks import pagination_system_check # NOQA diff --git a/rest_framework/checks.py b/rest_framework/checks.py new file mode 100644 index 000000000..af6634d1e --- /dev/null +++ b/rest_framework/checks.py @@ -0,0 +1,18 @@ +from django.core.checks import Tags, Warning, register + + +@register(Tags.compatibility) +def pagination_system_check(app_configs, **kwargs): + errors = [] + # Use of default page size setting requires a default Paginator class + from rest_framework.settings import api_settings + if api_settings.PAGE_SIZE and not api_settings.DEFAULT_PAGINATION_CLASS: + errors.append( + Warning( + "You have specified a default PAGE_SIZE pagination rest_framework setting," + "without specifying also a DEFAULT_PAGINATION_CLASS.", + hint="The default for DEFAULT_PAGINATION_CLASS is None. " + "In previous versions this was PageNumberPagination", + ) + ) + return errors diff --git a/rest_framework/settings.py b/rest_framework/settings.py index bc42c38a6..86b577219 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -51,7 +51,7 @@ DEFAULTS = { 'DEFAULT_VERSIONING_CLASS': None, # Generic view behavior - 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', + 'DEFAULT_PAGINATION_CLASS': None, 'DEFAULT_FILTER_BACKENDS': (), # Throttling From 5333565fe668646b45cca86f0029e0ccd80555d9 Mon Sep 17 00:00:00 2001 From: Katharyn Garcia Date: Mon, 25 Sep 2017 16:17:25 +0200 Subject: [PATCH 098/217] allow custom authentication and permission classes for docs view --- rest_framework/documentation.py | 21 ++++++++++++++++++--- rest_framework/schemas/__init__.py | 8 +++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/rest_framework/documentation.py b/rest_framework/documentation.py index 48458e188..9f9c828bc 100644 --- a/rest_framework/documentation.py +++ b/rest_framework/documentation.py @@ -4,11 +4,14 @@ from rest_framework.renderers import ( CoreJSONRenderer, DocumentationRenderer, SchemaJSRenderer ) from rest_framework.schemas import SchemaGenerator, get_schema_view +from rest_framework.settings import api_settings def get_docs_view( title=None, description=None, schema_url=None, public=True, - patterns=None, generator_class=SchemaGenerator): + patterns=None, generator_class=SchemaGenerator, + authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, + permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES): renderer_classes = [DocumentationRenderer, CoreJSONRenderer] return get_schema_view( @@ -19,12 +22,16 @@ def get_docs_view( public=public, patterns=patterns, generator_class=generator_class, + authentication_classes=authentication_classes, + permission_classes=permission_classes, ) def get_schemajs_view( title=None, description=None, schema_url=None, public=True, - patterns=None, generator_class=SchemaGenerator): + patterns=None, generator_class=SchemaGenerator, + authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, + permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES): renderer_classes = [SchemaJSRenderer] return get_schema_view( @@ -35,12 +42,16 @@ def get_schemajs_view( public=public, patterns=patterns, generator_class=generator_class, + authentication_classes=authentication_classes, + permission_classes=permission_classes, ) def include_docs_urls( title=None, description=None, schema_url=None, public=True, - patterns=None, generator_class=SchemaGenerator): + patterns=None, generator_class=SchemaGenerator, + authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, + permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES): docs_view = get_docs_view( title=title, description=description, @@ -48,6 +59,8 @@ def include_docs_urls( public=public, patterns=patterns, generator_class=generator_class, + authentication_classes=authentication_classes, + permission_classes=permission_classes, ) schema_js_view = get_schemajs_view( title=title, @@ -56,6 +69,8 @@ def include_docs_urls( public=public, patterns=patterns, generator_class=generator_class, + authentication_classes=authentication_classes, + permission_classes=permission_classes, ) urls = [ url(r'^$', docs_view, name='docs-index'), diff --git a/rest_framework/schemas/__init__.py b/rest_framework/schemas/__init__.py index fc551640e..1af0b9fc5 100644 --- a/rest_framework/schemas/__init__.py +++ b/rest_framework/schemas/__init__.py @@ -20,13 +20,17 @@ basic use-cases: Other access should target the submodules directly """ +from rest_framework.settings import api_settings + from .generators import SchemaGenerator from .inspectors import AutoSchema, ManualSchema # noqa def get_schema_view( title=None, url=None, description=None, urlconf=None, renderer_classes=None, - public=False, patterns=None, generator_class=SchemaGenerator): + public=False, patterns=None, generator_class=SchemaGenerator, + authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, + permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES): """ Return a schema view. """ @@ -40,4 +44,6 @@ def get_schema_view( renderer_classes=renderer_classes, schema_generator=generator, public=public, + authentication_classes=authentication_classes, + permission_classes=permission_classes, ) From 1bcee8c60c4429e1f841a32fcfe45a37f52fb0f8 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 25 Sep 2017 16:25:40 +0200 Subject: [PATCH 099/217] Document extra parameters to `get_schema_view` --- docs/api-guide/schemas.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index fc848199c..2cb29d5f8 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -334,6 +334,15 @@ to be exposed in the schema: May be used to specify a `SchemaGenerator` subclass to be passed to the `SchemaView`. +#### `authentication_classes` + +May be used to specify the list of authentication classes that will apply to the schema endpoint. +Defaults to `settings.DEFAULT_AUTHENTICATION_CLASSES` + +#### `permission_classes` + +May be used to specify the list of permission classes that will apply to the schema endpoint. +Defaults to `settings.DEFAULT_PERMISSION_CLASSES` ## Using an explicit schema view From bf0fbd5df174faf9e5399263c01d21e634470acf Mon Sep 17 00:00:00 2001 From: Sigve Sebastian Farstad Date: Mon, 25 Sep 2017 18:28:36 +0200 Subject: [PATCH 100/217] Catch APIException in doc generation (#5443) The documentation generator calls view.get_serializer() in order to inspect it for documentation generation. However, if get_serializer() throws an APIException (e.g. PermissionDenied), it doesn't get caught at the call site, but instead propagates up and aborts the entire view. With the try/except in this commit, the documentation generator instead gratiously ignores that particular view and moves on to the next one instead. Practical concequences of this commit is that the docs no longer break if any view's get_serializer(..) throws an APIException. --- rest_framework/schemas/inspectors.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index a91205cde..7f2c1cc71 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -4,13 +4,14 @@ inspectors.py # Per-endpoint view introspection See schemas.__init__.py for package overview. """ import re +import warnings from collections import OrderedDict from django.db import models from django.utils.encoding import force_text, smart_text from django.utils.translation import ugettext_lazy as _ -from rest_framework import serializers +from rest_framework import exceptions, serializers from rest_framework.compat import coreapi, coreschema, uritemplate, urlparse from rest_framework.settings import api_settings from rest_framework.utils import formatting @@ -285,7 +286,14 @@ class AutoSchema(ViewInspector): if not hasattr(view, 'get_serializer'): return [] - serializer = view.get_serializer() + try: + serializer = view.get_serializer() + except exceptions.APIException: + serializer = None + warnings.warn('{}.get_serializer() raised an exception during ' + 'schema generation. Serializer fields will not be ' + 'generated for {} {}.'.format( + type(view), method, path)) if isinstance(serializer, serializers.ListSerializer): return [ From 50acb9b2feb2fc3815e06cb881f81d3e16ff4864 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 25 Sep 2017 15:09:54 -0400 Subject: [PATCH 101/217] Fix warning in AutoSchema.get_serializer_fields() (#5451) --- rest_framework/schemas/inspectors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 7f2c1cc71..bdd720938 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -292,8 +292,8 @@ class AutoSchema(ViewInspector): serializer = None warnings.warn('{}.get_serializer() raised an exception during ' 'schema generation. Serializer fields will not be ' - 'generated for {} {}.'.format( - type(view), method, path)) + 'generated for {} {}.' + .format(view.__class__.__name__, method, path)) if isinstance(serializer, serializers.ListSerializer): return [ From 607e4edca77441f057ce40cd90175b1b5700f316 Mon Sep 17 00:00:00 2001 From: John Eskew Date: Tue, 26 Sep 2017 04:02:20 -0400 Subject: [PATCH 102/217] Defer translated string evaluation on validators. (#5452) * Customize validators to defer error string evaluation. * Add docstring for `CustomValidatorMessage` --- rest_framework/compat.py | 31 +++++++++++++++-- rest_framework/fields.py | 72 ++++++++++++++++++++++++++++------------ 2 files changed, 79 insertions(+), 24 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 528340d69..e0f718ced 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -11,13 +11,18 @@ import inspect import django from django.apps import apps from django.conf import settings -from django.core.exceptions import ImproperlyConfigured +from django.core.exceptions import ImproperlyConfigured, ValidationError +from django.core.validators import \ + MaxLengthValidator as DjangoMaxLengthValidator +from django.core.validators import MaxValueValidator as DjangoMaxValueValidator +from django.core.validators import \ + MinLengthValidator as DjangoMinLengthValidator +from django.core.validators import MinValueValidator as DjangoMinValueValidator from django.db import connection, models, transaction from django.template import Context, RequestContext, Template from django.utils import six from django.views.generic import View - try: from django.urls import ( NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve @@ -293,6 +298,28 @@ try: except ImportError: DecimalValidator = None +class CustomValidatorMessage(object): + """ + We need to avoid evaluation of `lazy` translated `message` in `django.core.validators.BaseValidator.__init__`. + https://github.com/django/django/blob/75ed5900321d170debef4ac452b8b3cf8a1c2384/django/core/validators.py#L297 + + Ref: https://github.com/encode/django-rest-framework/pull/5452 + """ + def __init__(self, *args, **kwargs): + self.message = kwargs.pop('message', self.message) + super(CustomValidatorMessage, self).__init__(*args, **kwargs) + +class MinValueValidator(CustomValidatorMessage, DjangoMinValueValidator): + pass + +class MaxValueValidator(CustomValidatorMessage, DjangoMaxValueValidator): + pass + +class MinLengthValidator(CustomValidatorMessage, DjangoMinLengthValidator): + pass + +class MaxLengthValidator(CustomValidatorMessage, DjangoMaxLengthValidator): + pass def set_rollback(): if hasattr(transaction, 'set_rollback'): diff --git a/rest_framework/fields.py b/rest_framework/fields.py index e17a0bf9a..1bcdf763d 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -13,8 +13,7 @@ from django.conf import settings from django.core.exceptions import ValidationError as DjangoValidationError from django.core.exceptions import ObjectDoesNotExist from django.core.validators import ( - EmailValidator, MaxLengthValidator, MaxValueValidator, MinLengthValidator, - MinValueValidator, RegexValidator, URLValidator, ip_address_validators + EmailValidator, RegexValidator, URLValidator, ip_address_validators ) from django.forms import FilePathField as DjangoFilePathField from django.forms import ImageField as DjangoImageField @@ -25,14 +24,16 @@ from django.utils.dateparse import ( from django.utils.duration import duration_string from django.utils.encoding import is_protected_type, smart_text from django.utils.formats import localize_input, sanitize_separators +from django.utils.functional import lazy from django.utils.ipv6 import clean_ipv6_address from django.utils.timezone import utc from django.utils.translation import ugettext_lazy as _ from rest_framework import ISO_8601 from rest_framework.compat import ( - InvalidTimeError, get_remote_field, unicode_repr, unicode_to_repr, - value_from_object + InvalidTimeError, MaxLengthValidator, MaxValueValidator, + MinLengthValidator, MinValueValidator, get_remote_field, unicode_repr, + unicode_to_repr, value_from_object ) from rest_framework.exceptions import ErrorDetail, ValidationError from rest_framework.settings import api_settings @@ -750,11 +751,17 @@ class CharField(Field): self.min_length = kwargs.pop('min_length', None) super(CharField, self).__init__(**kwargs) if self.max_length is not None: - message = self.error_messages['max_length'].format(max_length=self.max_length) - self.validators.append(MaxLengthValidator(self.max_length, message=message)) + message = lazy( + self.error_messages['max_length'].format, + six.text_type)(max_length=self.max_length) + self.validators.append( + MaxLengthValidator(self.max_length, message=message)) if self.min_length is not None: - message = self.error_messages['min_length'].format(min_length=self.min_length) - self.validators.append(MinLengthValidator(self.min_length, message=message)) + message = lazy( + self.error_messages['min_length'].format, + six.text_type)(min_length=self.min_length) + self.validators.append( + MinLengthValidator(self.min_length, message=message)) def run_validation(self, data=empty): # Test for the empty string here so that it does not get validated, @@ -909,11 +916,17 @@ class IntegerField(Field): self.min_value = kwargs.pop('min_value', None) super(IntegerField, self).__init__(**kwargs) if self.max_value is not None: - message = self.error_messages['max_value'].format(max_value=self.max_value) - self.validators.append(MaxValueValidator(self.max_value, message=message)) + message = lazy( + self.error_messages['max_value'].format, + six.text_type)(max_value=self.max_value) + self.validators.append( + MaxValueValidator(self.max_value, message=message)) if self.min_value is not None: - message = self.error_messages['min_value'].format(min_value=self.min_value) - self.validators.append(MinValueValidator(self.min_value, message=message)) + message = lazy( + self.error_messages['min_value'].format, + six.text_type)(min_value=self.min_value) + self.validators.append( + MinValueValidator(self.min_value, message=message)) def to_internal_value(self, data): if isinstance(data, six.text_type) and len(data) > self.MAX_STRING_LENGTH: @@ -943,11 +956,17 @@ class FloatField(Field): self.min_value = kwargs.pop('min_value', None) super(FloatField, self).__init__(**kwargs) if self.max_value is not None: - message = self.error_messages['max_value'].format(max_value=self.max_value) - self.validators.append(MaxValueValidator(self.max_value, message=message)) + message = lazy( + self.error_messages['max_value'].format, + six.text_type)(max_value=self.max_value) + self.validators.append( + MaxValueValidator(self.max_value, message=message)) if self.min_value is not None: - message = self.error_messages['min_value'].format(min_value=self.min_value) - self.validators.append(MinValueValidator(self.min_value, message=message)) + message = lazy( + self.error_messages['min_value'].format, + six.text_type)(min_value=self.min_value) + self.validators.append( + MinValueValidator(self.min_value, message=message)) def to_internal_value(self, data): @@ -996,11 +1015,17 @@ class DecimalField(Field): super(DecimalField, self).__init__(**kwargs) if self.max_value is not None: - message = self.error_messages['max_value'].format(max_value=self.max_value) - self.validators.append(MaxValueValidator(self.max_value, message=message)) + message = lazy( + self.error_messages['max_value'].format, + six.text_type)(max_value=self.max_value) + self.validators.append( + MaxValueValidator(self.max_value, message=message)) if self.min_value is not None: - message = self.error_messages['min_value'].format(min_value=self.min_value) - self.validators.append(MinValueValidator(self.min_value, message=message)) + message = lazy( + self.error_messages['min_value'].format, + six.text_type)(min_value=self.min_value) + self.validators.append( + MinValueValidator(self.min_value, message=message)) def to_internal_value(self, data): """ @@ -1797,8 +1822,11 @@ class ModelField(Field): max_length = kwargs.pop('max_length', None) super(ModelField, self).__init__(**kwargs) if max_length is not None: - message = self.error_messages['max_length'].format(max_length=max_length) - self.validators.append(MaxLengthValidator(max_length, message=message)) + message = lazy( + self.error_messages['max_length'].format, + six.text_type)(max_length=self.max_length) + self.validators.append( + MaxLengthValidator(self.max_length, message=message)) def to_internal_value(self, data): rel = get_remote_field(self.model_field, default=None) From ab7e5c4551b828415db192ed8e1d8c272ae60d11 Mon Sep 17 00:00:00 2001 From: Rokker Ruslan Date: Tue, 26 Sep 2017 11:24:30 +0300 Subject: [PATCH 103/217] Added default value for 'detail' param into 'ValidationError' exception (#5342) --- rest_framework/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 7cc3ba049..12fd41931 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -123,7 +123,7 @@ class ValidationError(APIException): default_detail = _('Invalid input.') default_code = 'invalid' - def __init__(self, detail, code=None): + def __init__(self, detail=None, code=None): if detail is None: detail = self.default_detail if code is None: From b1c6ea124069c413e9d1ad5d38f8597df82ff0fb Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 27 Sep 2017 09:13:10 +0200 Subject: [PATCH 104/217] Adjust schema get_filter_fields rules to match framework (#5454) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #5237 Generics/ModelViewset performs filtering on: list, retrieve, put, patch and destroy (plus method equivalents). i.e. on list plus anything that calls `get_object`. This PR makes schema generation follow that. It adds `AutoSchema._allows_filters()` which can be overridden in subclasses. I’ve made this initially “private” so we can make quick changes if needs be in a 3.7.1 etc. --- rest_framework/schemas/inspectors.py | 31 +++++++++++++++++++++------- tests/test_schemas.py | 18 ++++++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index bdd720938..30f639f5b 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -337,18 +337,33 @@ class AutoSchema(ViewInspector): paginator = view.pagination_class() return paginator.get_schema_fields(view) + def _allows_filters(self, path, method): + """ + Determine whether to include filter Fields in schema. + + Default implementation looks for ModelViewSet or GenericAPIView + actions/methods that cause filtering on the default implementation. + + Override to adjust behaviour for your view. + + Note: Introduced in v3.7: Initially "private" (i.e. with leading underscore) + to allow changes based on user experience. + """ + if getattr(self.view, 'filter_backends', None) is None: + return False + + if hasattr(self.view, 'action'): + return self.view.action in ["list", "retrieve", "update", "partial_update", "destroy"] + + return method.lower in ["get", "put", "patch", "delete"] + def get_filter_fields(self, path, method): - view = self.view - - if not is_list_view(path, method, view): - return [] - - if not getattr(view, 'filter_backends', None): + if not self._allows_filters(path, method): return [] fields = [] - for filter_backend in view.filter_backends: - fields += filter_backend().get_schema_fields(view) + for filter_backend in self.view.filter_backends: + fields += filter_backend().get_schema_fields(self.view) return fields def get_encoding(self, path, method): diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 184401a86..07c49b71d 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -139,7 +139,8 @@ class TestRouterGeneratedSchema(TestCase): url='/example/{id}/', action='get', fields=[ - coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + coreapi.Field('id', required=True, location='path', schema=coreschema.String()), + coreapi.Field('ordering', required=False, location='query', schema=coreschema.String(title='Ordering', description='Which field to use when ordering the results.')) ] ) } @@ -179,7 +180,8 @@ class TestRouterGeneratedSchema(TestCase): url='/example/{id}/', action='get', fields=[ - coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + coreapi.Field('id', required=True, location='path', schema=coreschema.String()), + coreapi.Field('ordering', required=False, location='query', schema=coreschema.String(title='Ordering', description='Which field to use when ordering the results.')) ] ), 'custom_action': coreapi.Link( @@ -225,7 +227,8 @@ class TestRouterGeneratedSchema(TestCase): fields=[ coreapi.Field('id', required=True, location='path', schema=coreschema.String()), coreapi.Field('a', required=True, location='form', schema=coreschema.String(title='A', description=('A field description'))), - coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B')) + coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B')), + coreapi.Field('ordering', required=False, location='query', schema=coreschema.String(title='Ordering', description='Which field to use when ordering the results.')) ] ), 'partial_update': coreapi.Link( @@ -235,14 +238,16 @@ class TestRouterGeneratedSchema(TestCase): fields=[ coreapi.Field('id', required=True, location='path', schema=coreschema.String()), coreapi.Field('a', required=False, location='form', schema=coreschema.String(title='A', description='A field description')), - coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B')) + coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B')), + coreapi.Field('ordering', required=False, location='query', schema=coreschema.String(title='Ordering', description='Which field to use when ordering the results.')) ] ), 'delete': coreapi.Link( url='/example/{id}/', action='delete', fields=[ - coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + coreapi.Field('id', required=True, location='path', schema=coreschema.String()), + coreapi.Field('ordering', required=False, location='query', schema=coreschema.String(title='Ordering', description='Which field to use when ordering the results.')) ] ) } @@ -450,7 +455,8 @@ class TestSchemaGeneratorWithMethodLimitedViewSets(TestCase): url='/example1/{id}/', action='get', fields=[ - coreapi.Field('id', required=True, location='path', schema=coreschema.String()) + coreapi.Field('id', required=True, location='path', schema=coreschema.String()), + coreapi.Field('ordering', required=False, location='query', schema=coreschema.String(title='Ordering', description='Which field to use when ordering the results.')) ] ) } From 296904099f1f87657e064d5915737cbb59fde079 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 27 Sep 2017 10:29:48 +0200 Subject: [PATCH 105/217] Update test matrix: Add Django 2.0, drop 1.8 (#5457) * Add Django 2.0 to tox/travis. Updated requirements * Drop Django 1.8 & 1.9 --- .travis.yml | 10 ++++++---- requirements/requirements-codestyle.txt | 4 ++-- requirements/requirements-documentation.txt | 2 +- requirements/requirements-optionals.txt | 4 ++-- requirements/requirements-packaging.txt | 4 ++-- requirements/requirements-testing.txt | 4 ++-- tox.ini | 10 ++++------ 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a91af809..6a3ce8c49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,9 @@ python: sudo: false env: - - DJANGO=1.8 - - DJANGO=1.9 - DJANGO=1.10 - DJANGO=1.11 + - DJANGO=2.0 - DJANGO=master matrix: @@ -21,8 +20,8 @@ matrix: env: DJANGO=master - python: "3.6" env: DJANGO=1.11 - - python: "3.3" - env: DJANGO=1.8 + - python: "3.6" + env: DJANGO=2.0 - python: "2.7" env: TOXENV="lint" - python: "2.7" @@ -30,11 +29,14 @@ matrix: exclude: - python: "2.7" env: DJANGO=master + - python: "2.7" + env: DJANGO=2.0 - python: "3.4" env: DJANGO=master allow_failures: - env: DJANGO=master + - env: DJANGO=2.0 install: - pip install tox tox-travis diff --git a/requirements/requirements-codestyle.txt b/requirements/requirements-codestyle.txt index 9bafbe391..a64cfa29f 100644 --- a/requirements/requirements-codestyle.txt +++ b/requirements/requirements-codestyle.txt @@ -1,7 +1,7 @@ # PEP8 code linting, which we run on all commits. -flake8==2.4.0 +flake8==3.4.1 flake8-tidy-imports==1.1.0 -pep8==1.5.7 +pep8==1.7.0 # Sort and lint imports isort==4.2.5 diff --git a/requirements/requirements-documentation.txt b/requirements/requirements-documentation.txt index 81aa70456..012ec99f1 100644 --- a/requirements/requirements-documentation.txt +++ b/requirements/requirements-documentation.txt @@ -1,2 +1,2 @@ # MkDocs to build our documentation. -mkdocs==0.16.2 +mkdocs==0.16.3 diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt index 319b7547a..67525bebc 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -1,7 +1,7 @@ # Optional packages which may be used with REST framework. pytz==2017.2 markdown==2.6.4 -django-guardian==1.4.8 +django-guardian==1.4.9 django-filter==1.0.4 -coreapi==2.2.4 +coreapi==2.3.1 coreschema==0.0.4 diff --git a/requirements/requirements-packaging.txt b/requirements/requirements-packaging.txt index f930bfa96..f12d4af0e 100644 --- a/requirements/requirements-packaging.txt +++ b/requirements/requirements-packaging.txt @@ -1,8 +1,8 @@ # Wheel for PyPI installs. -wheel==0.29.0 +wheel==0.30.0 # Twine for secured PyPI uploads. -twine==1.6.5 +twine==1.9.1 # Transifex client for managing translation resources. transifex-client==0.11 diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt index b9e168442..515cff78d 100644 --- a/requirements/requirements-testing.txt +++ b/requirements/requirements-testing.txt @@ -1,4 +1,4 @@ # PyTest for running the tests. -pytest==3.0.5 +pytest==3.2.2 pytest-django==3.1.2 -pytest-cov==2.4.0 +pytest-cov==2.5.1 diff --git a/tox.ini b/tox.ini index 698a0b745..9c91a4920 100644 --- a/tox.ini +++ b/tox.ini @@ -3,18 +3,17 @@ addopts=--tb=short [tox] envlist = - {py27,py33,py34,py35}-django18, - {py27,py34,py35}-django{19,110}, + {py27,py34,py35}-django110, {py27,py34,py35,py36}-django111, + {py34,py35,py36}-django20, {py35,py36}-djangomaster lint,docs [travis:env] DJANGO = - 1.8: django18 - 1.9: django19 1.10: django110 1.11: django111 + 2.0: django20 master: djangomaster [testenv] @@ -23,10 +22,9 @@ setenv = PYTHONDONTWRITEBYTECODE=1 PYTHONWARNINGS=once deps = - django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 django110: Django>=1.10,<1.11 django111: Django>=1.11,<2.0 + django20: Django>=2.0a1,<2.1 djangomaster: https://github.com/django/django/archive/master.tar.gz -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt From 760268ade2e29a60b151cde15a1a79685970e68a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 27 Sep 2017 10:51:45 +0200 Subject: [PATCH 106/217] Fixed a deprecation warning (#5058) --- 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 1bcdf763d..7a79ae93c 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1831,7 +1831,7 @@ class ModelField(Field): def to_internal_value(self, data): rel = get_remote_field(self.model_field, default=None) if rel is not None: - return rel.to._meta.get_field(rel.field_name).to_python(data) + return rel.model._meta.get_field(rel.field_name).to_python(data) return self.model_field.to_python(data) def get_attribute(self, obj): From 5c2290d97380ca15005f7d42ffceae04dc817dba Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 27 Sep 2017 12:23:54 +0200 Subject: [PATCH 107/217] Add note on not using floats with CursorPagination (#5459) Closes #5160, closes #5164. --- docs/api-guide/pagination.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index 7b5e5b3f6..b28f1616d 100644 --- a/docs/api-guide/pagination.md +++ b/docs/api-guide/pagination.md @@ -179,6 +179,10 @@ Proper usage of cursor pagination should have an ordering field that satisfies t * Should be an unchanging value, such as a timestamp, slug, or other field that is only set once, on creation. * Should be unique, or nearly unique. Millisecond precision timestamps are a good example. This implementation of cursor pagination uses a smart "position plus offset" style that allows it to properly support not-strictly-unique values as the ordering. * Should be a non-nullable value that can be coerced to a string. +* Should not be a float. Precision errors easily lead to incorrect results. + Hint: use decimals instead. + (If you already have a float field and must paginate on that, an + [example `CursorPagination` subclass that uses decimals to limit precision is available here][float_cursor_pagination_example].) * The field should have a database index. Using an ordering field that does not satisfy these constraints will generally still work, but you'll be losing some of the benefits of cursor pagination. @@ -317,3 +321,4 @@ The [`django-rest-framework-link-header-pagination` package][drf-link-header-pag [drf-proxy-pagination]: https://github.com/tuffnatty/drf-proxy-pagination [drf-link-header-pagination]: https://github.com/tbeadle/django-rest-framework-link-header-pagination [disqus-cursor-api]: http://cramer.io/2011/03/08/building-cursors-for-the-disqus-api +[float_cursor_pagination_example]: https://gist.github.com/keturn/8bc88525a183fd41c73ffb729b8865be#file-fpcursorpagination-py From 018e43e908e912b5e99dcc648b37a68ee59a58ed Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 29 Sep 2017 10:42:24 -0400 Subject: [PATCH 108/217] Remove old django-filter templates (#5465) --- .../templates/rest_framework/filters/django_filter.html | 6 ------ .../rest_framework/filters/django_filter_crispyforms.html | 5 ----- 2 files changed, 11 deletions(-) delete mode 100644 rest_framework/templates/rest_framework/filters/django_filter.html delete mode 100644 rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html diff --git a/rest_framework/templates/rest_framework/filters/django_filter.html b/rest_framework/templates/rest_framework/filters/django_filter.html deleted file mode 100644 index b116e3531..000000000 --- a/rest_framework/templates/rest_framework/filters/django_filter.html +++ /dev/null @@ -1,6 +0,0 @@ -{% load i18n %} -

{% trans "Field filters" %}

-
- {{ filter.form.as_p }} - -
diff --git a/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html b/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html deleted file mode 100644 index 171767c08..000000000 --- a/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html +++ /dev/null @@ -1,5 +0,0 @@ -{% load crispy_forms_tags %} -{% load i18n %} - -

{% trans "Field filters" %}

-{% crispy filter.form %} From efc427dfc8144855f28a20888bbe11b83cbfa08f Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 2 Oct 2017 08:59:53 +0200 Subject: [PATCH 109/217] Reuse 'apply_markdown' function in 'render_markdown' templatetag func (#5469) * reused 'apply_markdown' function in 'render_markdown' templatetag function * typo fixed --- rest_framework/templatetags/rest_framework.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index a2ee5ccdd..264b6444c 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -11,7 +11,8 @@ from django.utils.html import escape, format_html, smart_urlquote from django.utils.safestring import SafeData, mark_safe from rest_framework.compat import ( - NoReverseMatch, markdown, pygments_highlight, reverse, template_render + NoReverseMatch, apply_markdown, pygments_highlight, reverse, + template_render ) from rest_framework.renderers import HTMLFormRenderer from rest_framework.utils.urls import replace_query_param @@ -68,9 +69,9 @@ def form_for_link(link): @register.simple_tag def render_markdown(markdown_text): - if not markdown: + if apply_markdown is None: return markdown_text - return mark_safe(markdown.markdown(markdown_text)) + return mark_safe(apply_markdown(markdown_text)) @register.simple_tag From e6193cfd9e6391c635368b9c71ed545c8fc024d1 Mon Sep 17 00:00:00 2001 From: Shreyans Sheth Date: Mon, 2 Oct 2017 12:34:55 +0530 Subject: [PATCH 110/217] Added Response import in Code Snippet (#5468) Added `from rest_framework.response import Response` in the viewset code snippet example --- docs/tutorial/6-viewsets-and-routers.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/tutorial/6-viewsets-and-routers.md b/docs/tutorial/6-viewsets-and-routers.md index 6189c7771..252021e39 100644 --- a/docs/tutorial/6-viewsets-and-routers.md +++ b/docs/tutorial/6-viewsets-and-routers.md @@ -26,6 +26,7 @@ Here we've used the `ReadOnlyModelViewSet` class to automatically provide the de Next we're going to replace the `SnippetList`, `SnippetDetail` and `SnippetHighlight` view classes. We can remove the three views, and again replace them with a single class. from rest_framework.decorators import detail_route + from rest_framework.response import Response class SnippetViewSet(viewsets.ModelViewSet): """ From 62ecbf2817e5dbce8bd67f4b8ba257bb4c4eec8c Mon Sep 17 00:00:00 2001 From: Lim H Date: Mon, 2 Oct 2017 10:16:33 +0100 Subject: [PATCH 111/217] Add drf-openapi (#5470) * Add DRF OpenAPI as a 3rd party tool for DRF doc * Add image * Add third party packages section to schema doc * Add DRF OpenAPI reference --- docs/api-guide/schemas.md | 11 +++++++++++ docs/img/drf-openapi.png | Bin 0 -> 75416 bytes docs/topics/documenting-your-api.md | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 docs/img/drf-openapi.png diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 2cb29d5f8..51a6c00c6 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -765,10 +765,21 @@ Valid only if a `location="body"` field is included on the `Link`. A short description of the meaning and intended usage of the input field. +--- + +# Third party packages + +## DRF OpenAPI + +[DRF OpenAPI][drf-openapi] renders the schema generated by Django Rest Framework +in [OpenAPI][open-api] format. + + [cite]: https://blog.heroku.com/archives/2014/1/8/json_schema_for_heroku_platform_api [coreapi]: http://www.coreapi.org/ [corejson]: http://www.coreapi.org/specification/encoding/#core-json-encoding [open-api]: https://openapis.org/ +[drf-openapi]: https://github.com/limdauto/drf_openapi [json-hyperschema]: http://json-schema.org/latest/json-schema-hypermedia.html [api-blueprint]: https://apiblueprint.org/ [static-files]: https://docs.djangoproject.com/en/stable/howto/static-files/ diff --git a/docs/img/drf-openapi.png b/docs/img/drf-openapi.png new file mode 100644 index 0000000000000000000000000000000000000000..7a37e19d6136301b5ff43bea160db7e32d3a9b96 GIT binary patch literal 75416 zcmaI7by!s2*EWu#qJn@@N{UE>o8 zF(&GlzcaP~)a8MVxUx6~MoldCU-O5k`+M#hvJx1T!{j>{7?>DpN?OuySUJxxE~r^J zvg+FR{_Gtc9j&geUR_<$aq`{X-cmEOzh+{i<=~}x$3?}!`i6z$4J#KVJqraLGc7yM zYi4#j4&JwH0LE{1tLqz1EgBSbOf>JfX*qaqZ*NvsR$eo+2}&!@EiNJd{(Z|1c+1X1 zME;uWEyIQ&_xEJbC(u}NMU_ppowTaf&CLxfpD??iIKPy9L21S1<<-vaUU+PrPf!RG zj}YYNFK$t(t?eDe=~>?p^z7_hSWX$-*c|ZXtBbeq!6Cd7TyO2{HZe7Qfl-GbaVOt5HjK9~{irNM$ddASvF|8zd%&pyg{HJDSL!x45=H`3)2jw;Oa*IkvCng!V z1&plhC6v_Zx%iqOZ7Zv*I;NJv5z#gEjcvcWEK01C)3eH|YC3!RKv_AC9v=-YZ2w$d z5|myi!?MtTH1cjEi9VaI{sc;KVM(-^z`(NPIB-IVHD)kj4;rPH|EunWDyfI z&9;zrRTELtRQaU6V`X;S1_4zz9p>fyUR~Q#m8a+BQTV7){g&F=E09}NOu$fvPeSI; z$w_7{#1Le55EZ_@v3aq-e^OH=VlFocpOmmw+!W>8b$34L?SZEz9|ZX$Mn}$;76ZS7 zw)HfPoW0_TsyC%YM3~q@QgWo6lobu$e@P!+J6nBS{ltl$k(GtLb+h?HP^6fp!gt!Y z;TeTz(^Gj%xqq%NV{*&AzJ7Nca@MhO(qUwgY!$C;T}Yaa?;KjQtm^+X5wy0xF6Yz| z)IMn&+TFX`+rGS$NlO#a@0DEEpcnx*>M<@JUscTQs9LSS7cV-y`s>kdq-yKM^@By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q4T0Npzha?(LRCiY>A1&FPRdxB!Qq6wJFJP^?EiiqVvJIb)u5| zI82Nn%sl`--bZW^W*ev;2uS8yARstmd!)@U?t?U9hgtUeYeXgQ;GBIOP6us`ZS5KE zJ|jnLbP(iHL)`;6CN`Q#XpP=9vFrvqxCbbx@6Y}KIY34~Fs)UhXh3d}zk~*7*1OYE z-hk&KX_=q10Av479D8G$AsZlKK$o={pV8|BMdAJ2`!4*z^bob7l%%&p!bJ#Z;tlu> zP|Y3SiFyY#!gr;=ECqZz@5K}keE^wA+M+Z6UIF?IO#cAf3mAJlOCl9fo!?DHxxh1)gW>{m0P7ajze1)uK$o~fruvAz8 literal 0 HcmV?d00001 diff --git a/docs/topics/documenting-your-api.md b/docs/topics/documenting-your-api.md index da1dbe358..b68eb64ec 100644 --- a/docs/topics/documenting-your-api.md +++ b/docs/topics/documenting-your-api.md @@ -75,6 +75,23 @@ When using viewsets, you should use the relevant action names as delimiters. There are a number of mature third-party packages for providing API documentation. +#### DRF OpenAPI + +[DRF OpenAPI][drf-openapi] bridges the gap between OpenAPI specification and tool chain with the schema exposed +out-of-the-box by Django Rest Framework. Its goals are: + + * To be dropped into any existing DRF project without any code change necessary. + * Provide clear disctinction between request schema and response schema. + * Provide a versioning mechanism for each schema. Support defining schema by version range syntax, e.g. >1.0, <=2.0 + * Support multiple response codes, not just 200 + * All this information should be bound to view methods, not view classes. + +It also tries to stay current with the maturing schema generation mechanism provided by DRF. + +![Screenshot - DRF OpenAPI][image-drf-openapi] + +--- + #### DRF Docs [DRF Docs][drfdocs-repo] allows you to document Web APIs made with Django REST Framework and it is authored by Emmanouil Konstantinidis. It's made to work out of the box and its setup should not take more than a couple of minutes. Complete documentation can be found on the [website][drfdocs-website] while there is also a [demo][drfdocs-demo] available for people to see what it looks like. **Live API Endpoints** allow you to utilize the endpoints from within the documentation in a neat way. @@ -197,6 +214,8 @@ In this approach, rather than documenting the available API endpoints up front, To implement a hypermedia API you'll need to decide on an appropriate media type for the API, and implement a custom renderer and parser for that media type. The [REST, Hypermedia & HATEOAS][hypermedia-docs] section of the documentation includes pointers to background reading, as well as links to various hypermedia formats. [cite]: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven +[drf-openapi]: https://github.com/limdauto/drf_openapi/ +[image-drf-openapi]: ../img/drf-openapi.png [drfdocs-repo]: https://github.com/ekonstantinidis/django-rest-framework-docs [drfdocs-website]: http://www.drfdocs.com/ [drfdocs-demo]: http://demo.drfdocs.com/ From 063534ae50d3d15a307205c91ed5a25974b0a1f4 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 2 Oct 2017 11:44:29 +0200 Subject: [PATCH 112/217] Docstrings highlighting with pygments (#5462) * add 'docstrings-with-pygments' feature without packages checks and tests * move syntax_highlight doc filter in compatibility module and define it conditionally * typo fixed * add test for optional code highlight ('pygments' and 'markdown' packages must be installed) --- rest_framework/compat.py | 33 +++++++++++++++++++++++++ tests/test_description.py | 52 ++++++++++++++++++++++++++++++++++----- 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index e0f718ced..3b341a656 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -244,6 +244,7 @@ try: md = markdown.Markdown( extensions=extensions, extension_configs=extension_configs ) + md_filter_add_syntax_highlight(md) return md.convert(text) except ImportError: apply_markdown = None @@ -273,6 +274,38 @@ except ImportError: def pygments_css(style): return None +if markdown is not None and pygments is not None: + # starting from this blogpost and modified to support current markdown extensions API + # https://zerokspot.com/weblog/2008/06/18/syntax-highlighting-in-markdown-with-pygments/ + + from markdown.preprocessors import Preprocessor + import re + + class CodeBlockPreprocessor(Preprocessor): + pattern = re.compile( + r'^\s*@@ (.+?) @@\s*(.+?)^\s*@@', re.M|re.S) + + formatter = HtmlFormatter() + + def run(self, lines): + def repl(m): + try: + lexer = get_lexer_by_name(m.group(1)) + except (ValueError, NameError): + lexer = TextLexer() + code = m.group(2).replace('\t',' ') + code = pygments.highlight(code, lexer, self.formatter) + code = code.replace('\n\n', '\n \n').replace('\n', '
').replace('\\@','@') + return '\n\n%s\n\n' % code + ret = self.pattern.sub(repl, "\n".join(lines)) + return ret.split("\n") + + def md_filter_add_syntax_highlight(md): + md.preprocessors.add('highlight', CodeBlockPreprocessor(), "_begin") + return True +else: + def md_filter_add_syntax_highlight(md): + return False try: import pytz diff --git a/tests/test_description.py b/tests/test_description.py index 4df14ac55..a97550ed8 100644 --- a/tests/test_description.py +++ b/tests/test_description.py @@ -24,11 +24,36 @@ another header indented -# hash style header #""" +# hash style header # + +@@ json @@ +[{ + "alpha": 1, + "beta: "this is a string" +}] +@@""" # If markdown is installed we also test it's working # (and that our wrapped forces '=' to h2 and '-' to h3) +MARKED_DOWN_HILITE = """ +
[{
"alpha": 1,
\ + "beta: "this\ + is a \ +string"
}]
+ +


""" + +MARKED_DOWN_NOT_HILITE = """ +

@@ json @@ +[{ + "alpha": 1, + "beta: "this is a string" +}] +@@

""" + # We support markdown < 2.1 and markdown >= 2.1 MARKED_DOWN_lt_21 = """

an example docstring

    @@ -39,7 +64,7 @@ MARKED_DOWN_lt_21 = """

    an example docstring

    code block
     

    indented

    -

    hash style header

    """ +

    hash style header

    %s""" MARKED_DOWN_gte_21 = """

    an example docstring

      @@ -50,7 +75,7 @@ MARKED_DOWN_gte_21 = """

      an example docstring

      code block
       

      indented

      -

      hash style header

      """ +

      hash style header

      %s""" class TestViewNamesAndDescriptions(TestCase): @@ -78,7 +103,14 @@ class TestViewNamesAndDescriptions(TestCase): indented - # hash style header #""" + # hash style header # + + @@ json @@ + [{ + "alpha": 1, + "beta: "this is a string" + }] + @@""" assert MockView().get_view_description() == DESCRIPTION @@ -118,8 +150,16 @@ class TestViewNamesAndDescriptions(TestCase): Ensure markdown to HTML works as expected. """ if apply_markdown: - gte_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_gte_21 - lt_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_lt_21 + gte_21_match = ( + apply_markdown(DESCRIPTION) == ( + MARKED_DOWN_gte_21 % MARKED_DOWN_HILITE) or + apply_markdown(DESCRIPTION) == ( + MARKED_DOWN_gte_21 % MARKED_DOWN_NOT_HILITE)) + lt_21_match = ( + apply_markdown(DESCRIPTION) == ( + MARKED_DOWN_lt_21 % MARKED_DOWN_HILITE) or + apply_markdown(DESCRIPTION) == ( + MARKED_DOWN_lt_21 % MARKED_DOWN_NOT_HILITE)) assert gte_21_match or lt_21_match From dc4a98fbe887ba71cf76fa6830ae2176012ca848 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 2 Oct 2017 13:26:44 +0200 Subject: [PATCH 113/217] Fix documentation `data` rendering (#5472) * Add failing test for #5395 * Add data filter for use in templates Closes #5395 * Fix isort --- .../rest_framework/docs/document.html | 4 +-- .../rest_framework/docs/sidebar.html | 4 +-- rest_framework/templatetags/rest_framework.py | 14 ++++++++ tests/conftest.py | 3 ++ tests/test_renderers.py | 32 ++++++++++++++++++- tests/urls.py | 11 +++++-- 6 files changed, 61 insertions(+), 7 deletions(-) diff --git a/rest_framework/templates/rest_framework/docs/document.html b/rest_framework/templates/rest_framework/docs/document.html index 7a438f68d..7922142f3 100644 --- a/rest_framework/templates/rest_framework/docs/document.html +++ b/rest_framework/templates/rest_framework/docs/document.html @@ -13,8 +13,8 @@ {% if 'javascript' in langs %}{% include "rest_framework/docs/langs/javascript-intro.html" %}{% endif %} -{% if document.data %} -{% for section_key, section in document.data|items %} +{% if document|data %} +{% for section_key, section in document|data|items %} {% if section_key %}

      {{ section_key }}

      diff --git a/rest_framework/templates/rest_framework/docs/sidebar.html b/rest_framework/templates/rest_framework/docs/sidebar.html index 31708e784..d23787025 100644 --- a/rest_framework/templates/rest_framework/docs/sidebar.html +++ b/rest_framework/templates/rest_framework/docs/sidebar.html @@ -5,8 +5,8 @@


      """ MARKED_DOWN_NOT_HILITE = """ -

      @@ json @@ +

      json [{ "alpha": 1, "beta: "this is a string" -}] -@@

      """ +}]

      """ # We support markdown < 2.1 and markdown >= 2.1 MARKED_DOWN_lt_21 = """

      an example docstring

      @@ -105,12 +104,12 @@ class TestViewNamesAndDescriptions(TestCase): # hash style header # - @@ json @@ + ``` json [{ "alpha": 1, "beta: "this is a string" }] - @@""" + ```""" assert MockView().get_view_description() == DESCRIPTION @@ -150,15 +149,16 @@ class TestViewNamesAndDescriptions(TestCase): Ensure markdown to HTML works as expected. """ if apply_markdown: + md_applied = apply_markdown(DESCRIPTION) gte_21_match = ( - apply_markdown(DESCRIPTION) == ( + md_applied == ( MARKED_DOWN_gte_21 % MARKED_DOWN_HILITE) or - apply_markdown(DESCRIPTION) == ( + md_applied == ( MARKED_DOWN_gte_21 % MARKED_DOWN_NOT_HILITE)) lt_21_match = ( - apply_markdown(DESCRIPTION) == ( + md_applied == ( MARKED_DOWN_lt_21 % MARKED_DOWN_HILITE) or - apply_markdown(DESCRIPTION) == ( + md_applied == ( MARKED_DOWN_lt_21 % MARKED_DOWN_NOT_HILITE)) assert gte_21_match or lt_21_match From e67605f70758ca5992f33bbe3f7430c0c6261279 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Sat, 21 Oct 2017 08:32:47 +0200 Subject: [PATCH 143/217] Make Travis CI include/exclude faster to read --- .travis.yml | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a3ce8c49..6c72f5ed4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,23 +16,15 @@ env: matrix: fast_finish: true include: - - python: "3.6" - env: DJANGO=master - - python: "3.6" - env: DJANGO=1.11 - - python: "3.6" - env: DJANGO=2.0 - - python: "2.7" - env: TOXENV="lint" - - python: "2.7" - env: TOXENV="docs" + - { python: "3.6", env: DJANGO=master } + - { python: "3.6", env: DJANGO=1.11 } + - { python: "3.6", env: DJANGO=2.0 } + - { python: "2.7", env: TOXENV=lint } + - { python: "2.7", env: TOXENV=docs } exclude: - - python: "2.7" - env: DJANGO=master - - python: "2.7" - env: DJANGO=2.0 - - python: "3.4" - env: DJANGO=master + - { python: "2.7", env: DJANGO=master } + - { python: "2.7", env: DJANGO=2.0 } + - { python: "3.4", env: DJANGO=master } allow_failures: - env: DJANGO=master From 916a4a27ef6d045475a61a1131439d2597dfc2ce Mon Sep 17 00:00:00 2001 From: andrewhannum Date: Mon, 23 Oct 2017 04:02:04 -0600 Subject: [PATCH 144/217] Interactive docs - make bottom sidebar items sticky (#5516) --- rest_framework/static/rest_framework/docs/css/base.css | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rest_framework/static/rest_framework/docs/css/base.css b/rest_framework/static/rest_framework/docs/css/base.css index b7ae6375e..97728e3c6 100644 --- a/rest_framework/static/rest_framework/docs/css/base.css +++ b/rest_framework/static/rest_framework/docs/css/base.css @@ -64,6 +64,10 @@ pre.highlight code { display: none; } +.sidebar .menu-list { + width: inherit; +} + .sidebar .menu-list ul, .sidebar .menu-list li { background: #2e353d; @@ -194,7 +198,8 @@ body { .sidebar .menu-list.menu-list-bottom { margin-bottom: 0; - position: absolute; + position: fixed; + width: inherit; bottom: 0; left: 0; right: 0; From 1c9ad52cb6105c442b48fab2e2114969729b0ed9 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 23 Oct 2017 12:31:59 +0200 Subject: [PATCH 145/217] Clarify pagination system check (#5524) * Add `id` to allow silencing. * Expand `hint` to clarify. Ref #5170 Closes #5523 --- rest_framework/checks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/checks.py b/rest_framework/checks.py index af6634d1e..c1e626018 100644 --- a/rest_framework/checks.py +++ b/rest_framework/checks.py @@ -12,7 +12,10 @@ def pagination_system_check(app_configs, **kwargs): "You have specified a default PAGE_SIZE pagination rest_framework setting," "without specifying also a DEFAULT_PAGINATION_CLASS.", hint="The default for DEFAULT_PAGINATION_CLASS is None. " - "In previous versions this was PageNumberPagination", + "In previous versions this was PageNumberPagination. " + "If you wish to define PAGE_SIZE globally whilst defining " + "pagination_class on a per-view basis you may silence this check.", + id="rest_framework.W001" ) ) return errors From 91fa8b923a51e51bafebcfa15e6e8ebab928642e Mon Sep 17 00:00:00 2001 From: Jamie Cockburn Date: Wed, 25 Oct 2017 09:54:38 +0100 Subject: [PATCH 146/217] Stop JSONBoundField mangling invalid JSON (#5526) (#5527) --- rest_framework/utils/serializer_helpers.py | 11 +++++++---- tests/test_bound_fields.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index fa79b6526..6b662a66c 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -86,10 +86,13 @@ class BoundField(object): class JSONBoundField(BoundField): def as_form_field(self): value = self.value - try: - value = json.dumps(self.value, sort_keys=True, indent=4) - except (TypeError, ValueError): - pass + # When HTML form input is used and the input is not valid + # value will be a JSONString, rather than a JSON primitive. + if not getattr(value, 'is_json_string', False): + try: + value = json.dumps(self.value, sort_keys=True, indent=4) + except (TypeError, ValueError): + pass return self.__class__(self._field, value, self.errors, self._prefix) diff --git a/tests/test_bound_fields.py b/tests/test_bound_fields.py index ade739d41..e90e65edf 100644 --- a/tests/test_bound_fields.py +++ b/tests/test_bound_fields.py @@ -1,3 +1,5 @@ +from django.http import QueryDict + from rest_framework import serializers @@ -160,3 +162,15 @@ class TestNestedBoundField: ) rendered_packed = ''.join(rendered.split()) assert rendered_packed == expected_packed + + +class TestJSONBoundField: + def test_as_form_fields(self): + class TestSerializer(serializers.Serializer): + json_field = serializers.JSONField() + + data = QueryDict(mutable=True) + data.update({'json_field': '{"some": ["json"}'}) + serializer = TestSerializer(data=data) + assert serializer.is_valid() is False + assert serializer['json_field'].as_form_field().value == '{"some": ["json"}' From efb047fa07c187e2a506d9eaf7d4e60a98fe9d62 Mon Sep 17 00:00:00 2001 From: Jamie Cockburn Date: Wed, 25 Oct 2017 09:55:41 +0100 Subject: [PATCH 147/217] JSONField renders as textarea (#5529) (#5530) --- rest_framework/renderers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 9d187001f..0198f3e8c 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -323,6 +323,9 @@ class HTMLFormRenderer(BaseRenderer): serializers.FilePathField: { 'base_template': 'select.html', }, + serializers.JSONField: { + 'base_template': 'textarea.html', + }, }) def render_field(self, field, parent_style): From 7261ae653a36a3cc918326f56331e81c4252a141 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 25 Oct 2017 10:56:40 +0200 Subject: [PATCH 148/217] Schema: Exclude OPTIONS/HEAD for ViewSet actions (#5532) Closes #5528. Viewset custom actions (@detail_route etc) OPTIONS (and HEAD) methods were not being excluded from Schema Generations. This PR adds a test reproducing the reported error and adjusts `EndpointEnumerator.get_allowed_methods()` to filter ViewSet actions in the same way as other `APIView`s --- rest_framework/schemas/generators.py | 9 +++-- tests/test_schemas.py | 50 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 5fac35276..393e21575 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -222,12 +222,11 @@ class EndpointEnumerator(object): if hasattr(callback, 'actions'): actions = set(callback.actions.keys()) http_method_names = set(callback.cls.http_method_names) - return [method.upper() for method in actions & http_method_names] + methods = [method.upper() for method in actions & http_method_names] + else: + methods = callback.cls().allowed_methods - return [ - method for method in - callback.cls().allowed_methods if method not in ('OPTIONS', 'HEAD') - ] + return [method for method in methods if method not in ('OPTIONS', 'HEAD')] class SchemaGenerator(object): diff --git a/tests/test_schemas.py b/tests/test_schemas.py index eec3060fb..df4910301 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -901,3 +901,53 @@ def test_is_list_view_recognises_retrieve_view_subclasses(): is_list = is_list_view(path, method, view) assert not is_list, "RetrieveAPIView subclasses should not be classified as list views." + + +def test_head_and_options_methods_are_excluded(): + """ + Regression test for #5528 + https://github.com/encode/django-rest-framework/issues/5528 + + Viewset OPTIONS actions were not being correctly excluded + + Initial cases here shown to be working as expected. + """ + + @api_view(['options', 'get']) + def fbv(request): + pass + + inspector = EndpointEnumerator() + + path = '/a/path/' + callback = fbv + + assert inspector.should_include_endpoint(path, callback) + assert inspector.get_allowed_methods(callback) == ["GET"] + + class AnAPIView(APIView): + + def get(self, request, *args, **kwargs): + pass + + def options(self, request, *args, **kwargs): + pass + + callback = AnAPIView.as_view() + + assert inspector.should_include_endpoint(path, callback) + assert inspector.get_allowed_methods(callback) == ["GET"] + + class AViewSet(ModelViewSet): + + @detail_route(methods=['options', 'get']) + def custom_action(self, request, pk): + pass + + callback = AViewSet.as_view({ + "options": "custom_action", + "get": "custom_action" + }) + + assert inspector.should_include_endpoint(path, callback) + assert inspector.get_allowed_methods(callback) == ["GET"] From 1f693c331ee39d4c769e1408edd441894894f474 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 25 Oct 2017 11:46:21 +0200 Subject: [PATCH 149/217] Fix dotted source ordering (#5533) * replaced '.' for '__' in dotted ordering sources * Add test for non-dotted source. --- rest_framework/filters.py | 2 +- tests/test_filters.py | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 28b6995ec..d30135d2e 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -199,7 +199,7 @@ class OrderingFilter(BaseFilterBackend): raise ImproperlyConfigured(msg % self.__class__.__name__) return [ - (field.source or field_name, field.label) + (field.source.replace('.', '__') or field_name, field.label) for field_name, field in serializer_class(context=context).fields.items() if not getattr(field, 'write_only', False) and not field.source == '*' ] diff --git a/tests/test_filters.py b/tests/test_filters.py index dc5b18068..970f6bdfc 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -312,6 +312,7 @@ class OrderingFilterModel(models.Model): class OrderingFilterRelatedModel(models.Model): related_object = models.ForeignKey(OrderingFilterModel, related_name="relateds", on_delete=models.CASCADE) + index = models.SmallIntegerField(help_text="A non-related field to test with", default=0) class OrderingFilterSerializer(serializers.ModelSerializer): @@ -320,6 +321,19 @@ class OrderingFilterSerializer(serializers.ModelSerializer): fields = '__all__' +class OrderingDottedRelatedSerializer(serializers.ModelSerializer): + related_text = serializers.CharField(source='related_object.text') + related_title = serializers.CharField(source='related_object.title') + + class Meta: + model = OrderingFilterRelatedModel + fields = ( + 'related_text', + 'related_title', + 'index', + ) + + class DjangoFilterOrderingModel(models.Model): date = models.DateField() text = models.CharField(max_length=10) @@ -484,6 +498,36 @@ class OrderingFilterTests(TestCase): {'id': 2, 'title': 'yxw', 'text': 'bcd'}, ] + def test_ordering_by_dotted_source(self): + + for index, obj in enumerate(OrderingFilterModel.objects.all()): + OrderingFilterRelatedModel.objects.create( + related_object=obj, + index=index + ) + + class OrderingListView(generics.ListAPIView): + serializer_class = OrderingDottedRelatedSerializer + filter_backends = (filters.OrderingFilter,) + queryset = OrderingFilterRelatedModel.objects.all() + + view = OrderingListView.as_view() + request = factory.get('/', {'ordering': 'related_object__text'}) + response = view(request) + assert response.data == [ + {'related_title': 'zyx', 'related_text': 'abc', 'index': 0}, + {'related_title': 'yxw', 'related_text': 'bcd', 'index': 1}, + {'related_title': 'xwv', 'related_text': 'cde', 'index': 2}, + ] + + request = factory.get('/', {'ordering': '-index'}) + response = view(request) + assert response.data == [ + {'related_title': 'xwv', 'related_text': 'cde', 'index': 2}, + {'related_title': 'yxw', 'related_text': 'bcd', 'index': 1}, + {'related_title': 'zyx', 'related_text': 'abc', 'index': 0}, + ] + def test_ordering_with_nonstandard_ordering_param(self): with override_settings(REST_FRAMEWORK={'ORDERING_PARAM': 'order'}): reload_module(filters) From 5009aeff180085d7d3a82c37d8f992d521d612a2 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 30 Oct 2017 05:17:53 -0400 Subject: [PATCH 150/217] Fields with 'allow_null=True' should imply a default serialization value (#5518) * Add test for dotted source + allow_null * Field 'allow_null' implies 'default=None' * Field 'allow_null' provides serialization default --- rest_framework/fields.py | 2 ++ tests/test_serializer.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 43fed9aee..ab8f2eb44 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -442,6 +442,8 @@ class Field(object): except (KeyError, AttributeError) as exc: if self.default is not empty: return self.get_default() + if self.allow_null: + return None if not self.required: raise SkipField() msg = ( diff --git a/tests/test_serializer.py b/tests/test_serializer.py index bb78af63a..df8839356 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -449,6 +449,14 @@ class TestDefaultOutput: assert Serializer({'nested': {'a': '3', 'b': {}}}).data == {'nested': {'a': '3', 'c': '2'}} assert Serializer({'nested': {'a': '3', 'b': {'c': '4'}}}).data == {'nested': {'a': '3', 'c': '4'}} + def test_default_for_allow_null(self): + # allow_null=True should imply default=None + class Serializer(serializers.Serializer): + foo = serializers.CharField() + bar = serializers.CharField(source='foo.bar', allow_null=True) + + assert Serializer({'foo': None}).data == {'foo': None, 'bar': None} + class TestCacheSerializerData: def test_cache_serializer_data(self): From 2b6245db5359571f10d27ace16473d70e160dce2 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 30 Oct 2017 13:08:52 +0000 Subject: [PATCH 151/217] Ensure Location header is strictly a 'str', not subclass. Closes #5541 (#5544) --- rest_framework/mixins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index f3695e665..de10d6930 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -27,7 +27,7 @@ class CreateModelMixin(object): def get_success_headers(self, data): try: - return {'Location': data[api_settings.URL_FIELD_NAME]} + return {'Location': str(data[api_settings.URL_FIELD_NAME])} except (TypeError, KeyError): return {} From 4249245123f2bae425363292de689bd291d0573b Mon Sep 17 00:00:00 2001 From: Danilo Akamine Date: Mon, 30 Oct 2017 12:11:54 -0400 Subject: [PATCH 152/217] Add import to example in api-guide/parsers (#5547) --- docs/api-guide/parsers.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api-guide/parsers.md b/docs/api-guide/parsers.md index 7bf932d06..cd5ef1a04 100644 --- a/docs/api-guide/parsers.md +++ b/docs/api-guide/parsers.md @@ -54,6 +54,7 @@ Or, if you're using the `@api_view` decorator with function based views. from rest_framework.decorators import api_view from rest_framework.decorators import parser_classes + from rest_framework.parsers import JSONParser @api_view(['POST']) @parser_classes((JSONParser,)) From 93e75ec13831685fed03c35a773c8771374ecece Mon Sep 17 00:00:00 2001 From: Stephen Chisholm Date: Tue, 31 Oct 2017 06:17:08 -0300 Subject: [PATCH 153/217] Catch OverflowError for "out of range" datetimes (#5546) * Add test for #5545 * Catch OverflowError for "out of range" datetimes --- rest_framework/fields.py | 8 ++++++-- tests/test_fields.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index ab8f2eb44..9cfd39995 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1131,7 +1131,8 @@ class DateTimeField(Field): default_error_messages = { 'invalid': _('Datetime has wrong format. Use one of these formats instead: {format}.'), 'date': _('Expected a datetime but got a date.'), - 'make_aware': _('Invalid datetime for the timezone "{timezone}".') + 'make_aware': _('Invalid datetime for the timezone "{timezone}".'), + 'overflow': _('Datetime value out of range.') } datetime_parser = datetime.datetime.strptime @@ -1153,7 +1154,10 @@ class DateTimeField(Field): if field_timezone is not None: if timezone.is_aware(value): - return value.astimezone(field_timezone) + try: + return value.astimezone(field_timezone) + except OverflowError: + self.fail('overflow') try: return timezone.make_aware(value, field_timezone) except InvalidTimeError: diff --git a/tests/test_fields.py b/tests/test_fields.py index c1b99818a..2f642a77c 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1171,6 +1171,7 @@ class TestDateTimeField(FieldValues): '2001-99-99T99:00': ['Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].'], '2018-08-16 22:00-24:00': ['Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].'], datetime.date(2001, 1, 1): ['Expected a datetime but got a date.'], + '9999-12-31T21:59:59.99990-03:00': ['Datetime value out of range.'], } outputs = { datetime.datetime(2001, 1, 1, 13, 00): '2001-01-01T13:00:00Z', From 3ddc22f708c48def1efbab50a677121fa4191833 Mon Sep 17 00:00:00 2001 From: Allisson Azevedo Date: Thu, 2 Nov 2017 06:19:33 -0300 Subject: [PATCH 154/217] Add djangorestframework-rapidjson to third party packages (#5549) --- docs/topics/third-party-packages.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/third-party-packages.md b/docs/topics/third-party-packages.md index 035335a82..38ece4e5d 100644 --- a/docs/topics/third-party-packages.md +++ b/docs/topics/third-party-packages.md @@ -239,6 +239,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque * [djangorestframework-jsonapi][djangorestframework-jsonapi] - Provides a parser, renderer, serializers, and other tools to help build an API that is compliant with the jsonapi.org spec. * [drf_ujson][drf_ujson] - Implements JSON rendering using the UJSON package. * [rest-pandas][rest-pandas] - Pandas DataFrame-powered renderers including Excel, CSV, and SVG formats. +* [djangorestframework-rapidjson][djangorestframework-rapidjson] - Provides rapidjson support with parser and renderer. ### Filtering @@ -306,6 +307,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque [djangorestframework-csv]: https://github.com/mjumbewu/django-rest-framework-csv [drf_ujson]: https://github.com/gizmag/drf-ujson-renderer [rest-pandas]: https://github.com/wq/django-rest-pandas +[djangorestframework-rapidjson]: https://github.com/allisson/django-rest-framework-rapidjson [djangorestframework-chain]: https://github.com/philipn/django-rest-framework-chain [djangorestrelationalhyperlink]: https://github.com/fredkingham/django_rest_model_hyperlink_serializers_project [django-rest-swagger]: https://github.com/marcgibbons/django-rest-swagger From 5d71d8d4b8d49e6463ed35114e175f3e2b09488b Mon Sep 17 00:00:00 2001 From: Vasyl Dizhak Date: Thu, 2 Nov 2017 10:26:42 +0100 Subject: [PATCH 155/217] Increase test coverage for drf_create_token command (#5550) --- tests/test_authtoken.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_authtoken.py b/tests/test_authtoken.py index 5df053da3..c8957f978 100644 --- a/tests/test_authtoken.py +++ b/tests/test_authtoken.py @@ -1,7 +1,7 @@ import pytest from django.contrib.admin import site from django.contrib.auth.models import User -from django.core.management import call_command +from django.core.management import CommandError, call_command from django.test import TestCase from django.utils.six import StringIO @@ -71,6 +71,11 @@ class AuthTokenCommandTests(TestCase): assert first_token_key == second_token_key + def test_command_raising_error_for_invalid_user(self): + out = StringIO() + with pytest.raises(CommandError): + call_command('drf_create_token', 'not_existing_user', stdout=out) + def test_command_output(self): out = StringIO() call_command('drf_create_token', self.user.username, stdout=out) From 1575bd98d80a676b3f962e15320ad1ecdab191bb Mon Sep 17 00:00:00 2001 From: Adrien Brunet Date: Fri, 3 Nov 2017 15:49:21 +0100 Subject: [PATCH 156/217] Update link to documentation Previous link led to a maze. :/ --- docs/api-guide/filtering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index b52dd90d9..93a142755 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -381,7 +381,7 @@ The [djangorestframework-word-filter][django-rest-framework-word-search-filter] [cite]: https://docs.djangoproject.com/en/stable/topics/db/queries/#retrieving-specific-objects-with-filters [django-filter]: https://github.com/alex/django-filter [django-filter-docs]: https://django-filter.readthedocs.io/en/latest/index.html -[django-filter-drf-docs]: https://django-filter.readthedocs.io/en/develop/guide/rest_framework.html +[django-filter-drf-docs]: https://django-filter.readthedocs.io/en/latest/guide/rest_framework.html [guardian]: https://django-guardian.readthedocs.io/ [view-permissions]: https://django-guardian.readthedocs.io/en/latest/userguide/assign.html [view-permissions-blogpost]: http://blog.nyaruka.com/adding-a-view-permission-to-django-models From 64cfa3b64ddfc51d588ffcf4b946dd7514b7365b Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 3 Nov 2017 16:03:05 -0700 Subject: [PATCH 157/217] Add trove classifier for Python 3.6 support. Helps users know, at a glance, if the library is compatible with a project. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index f9f8a7bb4..385413052 100755 --- a/setup.py +++ b/setup.py @@ -103,6 +103,7 @@ setup( 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Internet :: WWW/HTTP', ] ) From 18180c9fc648d48319e61bb0fcbe19fb827b6bb0 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 3 Nov 2017 16:08:34 -0700 Subject: [PATCH 158/217] Add pip cache support to the Travis CI configuration For documentation on the feature, see: https://docs.travis-ci.com/user/caching/#pip-cache With packages cached, builds will be slightly faster and help reduce load on PyPI. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6c72f5ed4..05309cd97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +cache: pip python: - "2.7" From da266fb864a0f8939a7b1d3f522f76c6d170cf18 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 3 Nov 2017 17:40:14 -0700 Subject: [PATCH 159/217] Rename [wheel] section to [bdist_wheel] as the former is legacy For additional details, see: https://bitbucket.org/pypa/wheel/src/54ddbcc9cec25e1f4d111a142b8bfaa163130a61/wheel/bdist_wheel.py?fileviewer=file-view-default#bdist_wheel.py-119:125 http://pythonwheels.com/ --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 9f6b5be77..aa34f62b7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,4 @@ -[wheel] +[bdist_wheel] universal = 1 [metadata] From 44823b0e1d34f4591b0bd07bb19151ea519884c6 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 5 Nov 2017 10:09:38 -0800 Subject: [PATCH 160/217] Fix invalid escape sequence deprecation warnings When running tests with warnings enabled, appear as: DeprecationWarning: invalid escape sequence \d Starting with Python 3.6, invalid escape sequences are deprecated. In a future Python versions they will be a syntax error. For more details, see: https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior > A backslash-character pair that is not a valid escape sequence now > generates a DeprecationWarning. Although this will eventually become a > SyntaxError, that will not be for several Python releases. --- tests/test_schemas.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_schemas.py b/tests/test_schemas.py index df4910301..1a84dfc89 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -313,9 +313,9 @@ class ExampleDetailView(APIView): class TestSchemaGenerator(TestCase): def setUp(self): self.patterns = [ - url('^example/?$', ExampleListView.as_view()), - url('^example/(?P\d+)/?$', ExampleDetailView.as_view()), - url('^example/(?P\d+)/sub/?$', ExampleDetailView.as_view()), + url(r'^example/?$', ExampleListView.as_view()), + url(r'^example/(?P\d+)/?$', ExampleDetailView.as_view()), + url(r'^example/(?P\d+)/sub/?$', ExampleDetailView.as_view()), ] def test_schema_for_regular_views(self): @@ -365,9 +365,9 @@ class TestSchemaGenerator(TestCase): class TestSchemaGeneratorNotAtRoot(TestCase): def setUp(self): self.patterns = [ - url('^api/v1/example/?$', ExampleListView.as_view()), - url('^api/v1/example/(?P\d+)/?$', ExampleDetailView.as_view()), - url('^api/v1/example/(?P\d+)/sub/?$', ExampleDetailView.as_view()), + url(r'^api/v1/example/?$', ExampleListView.as_view()), + url(r'^api/v1/example/(?P\d+)/?$', ExampleDetailView.as_view()), + url(r'^api/v1/example/(?P\d+)/sub/?$', ExampleDetailView.as_view()), ] def test_schema_for_regular_views(self): From 565c722762b623bf0c5da68eab2860b3c86fdb48 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 6 Nov 2017 09:04:07 +0100 Subject: [PATCH 161/217] Add interactive docs error template (#5548) --- rest_framework/renderers.py | 17 ++++- .../templates/rest_framework/docs/error.html | 75 +++++++++++++++++++ 2 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 rest_framework/templates/rest_framework/docs/error.html diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 0198f3e8c..a7508bb7c 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -812,6 +812,7 @@ class DocumentationRenderer(BaseRenderer): format = 'html' charset = 'utf-8' template = 'rest_framework/docs/index.html' + error_template = 'rest_framework/docs/error.html' code_style = 'emacs' languages = ['shell', 'javascript', 'python'] @@ -824,9 +825,19 @@ class DocumentationRenderer(BaseRenderer): } def render(self, data, accepted_media_type=None, renderer_context=None): - template = loader.get_template(self.template) - context = self.get_context(data, renderer_context['request']) - return template.render(context, request=renderer_context['request']) + if isinstance(data, coreapi.Document): + template = loader.get_template(self.template) + context = self.get_context(data, renderer_context['request']) + return template.render(context, request=renderer_context['request']) + else: + template = loader.get_template(self.error_template) + context = { + "data": data, + "request": renderer_context['request'], + "response": renderer_context['response'], + "debug": settings.DEBUG, + } + return template.render(context, request=renderer_context['request']) class SchemaJSRenderer(BaseRenderer): diff --git a/rest_framework/templates/rest_framework/docs/error.html b/rest_framework/templates/rest_framework/docs/error.html new file mode 100644 index 000000000..15bfb1037 --- /dev/null +++ b/rest_framework/templates/rest_framework/docs/error.html @@ -0,0 +1,75 @@ +{% load staticfiles %} + + + + + + + + Error Rendering Schema + + + + + +

      Error

      + +
      +{{ data }}
      +
      + + +{% if debug is True %} +
      +

      Additional Information

      +

      Note: You are seeing this message because DEBUG==True.

      + +

      Seeing this page is usually a configuration error: are your +DEFAULT_AUTHENTICATION_CLASSES or DEFAULT_PERMISSION_CLASSES +being applied unexpectedly?

      + +

      Your response status code is: {{ response.status_code }}

      + +

      401 Unauthorised.

      +
        +
      • Do you have SessionAuthentication enabled?
      • +
      • Are you logged in?
      • +
      + + +

      403 Forbidden.

      +
        +
      • Do you have sufficient permissions to access this view?
      • +
      • Is you schema non-empty? (An empty schema will lead to a permission denied error being raised.)
      • +
      + + +

      Most commonly the intended solution is to disable authentication and permissions +when including the docs urls:

      + +
      +   url(r'^docs/', include_docs_urls(title='Your API',
      +                                    authentication_classes=[],
      +                                    permission_classes=[])),
      +
      + + +

      Overriding this template

      + +

      If you wish access to your docs to be authenticated you may override this template +at rest_framework/docs/error.html.

      + +

      The available context is: data the error dict above, request, +response and the debug flag.

      + +{% endif %} + + + + + + + + + + From 331c31370f673b1e3448685fc9342c180a686b2f Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 6 Nov 2017 09:55:09 +0100 Subject: [PATCH 162/217] Add rounding parameter to DecimalField (#5562) * Adding rounding parameter to DecimalField. * Using standard `assert` instead of `self.fail()`. * add testcase and PEP8 multilines fix * flake8 fixes * Use decimal module constants in tests. * Add docs note for `rounding` parameter. --- docs/api-guide/fields.md | 2 ++ rest_framework/fields.py | 9 ++++++++- tests/test_fields.py | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 3d2443c5c..64014b56e 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -269,6 +269,7 @@ Corresponds to `django.db.models.fields.DecimalField`. - `max_value` Validate that the number provided is no greater than this value. - `min_value` Validate that the number provided is no less than this value. - `localize` Set to `True` to enable localization of input and output based on the current locale. This will also force `coerce_to_string` to `True`. Defaults to `False`. Note that data formatting is enabled if you have set `USE_L10N=True` in your settings file. +- `rounding` Sets the rounding mode used when quantising to the configured precision. Valid values are [`decimal` module rounding modes][python-decimal-rounding-modes]. Defaults to `None`. #### Example usage @@ -680,3 +681,4 @@ The [django-rest-framework-hstore][django-rest-framework-hstore] package provide [django-rest-framework-gis]: https://github.com/djangonauts/django-rest-framework-gis [django-rest-framework-hstore]: https://github.com/djangonauts/django-rest-framework-hstore [django-hstore]: https://github.com/djangonauts/django-hstore +[python-decimal-rounding-modes]: https://docs.python.org/3/library/decimal.html#rounding-modes \ No newline at end of file diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 9cfd39995..dd852f3c6 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -997,7 +997,7 @@ class DecimalField(Field): MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs. def __init__(self, max_digits, decimal_places, coerce_to_string=None, max_value=None, min_value=None, - localize=False, **kwargs): + localize=False, rounding=None, **kwargs): self.max_digits = max_digits self.decimal_places = decimal_places self.localize = localize @@ -1029,6 +1029,12 @@ class DecimalField(Field): self.validators.append( MinValueValidator(self.min_value, message=message)) + if rounding is not None: + valid_roundings = [v for k, v in vars(decimal).items() if k.startswith('ROUND_')] + assert rounding in valid_roundings, ( + 'Invalid rounding option %s. Valid values for rounding are: %s' % (rounding, valid_roundings)) + self.rounding = rounding + def to_internal_value(self, data): """ Validate that the input is a decimal number and return a Decimal @@ -1121,6 +1127,7 @@ class DecimalField(Field): context.prec = self.max_digits return value.quantize( decimal.Decimal('.1') ** self.decimal_places, + rounding=self.rounding, context=context ) diff --git a/tests/test_fields.py b/tests/test_fields.py index 2f642a77c..876dd39c8 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -3,7 +3,7 @@ import os import re import unittest import uuid -from decimal import Decimal +from decimal import ROUND_DOWN, ROUND_UP, Decimal import django import pytest @@ -1092,8 +1092,21 @@ class TestNoDecimalPlaces(FieldValues): field = serializers.DecimalField(max_digits=6, decimal_places=None) -# Date & time serializers... +class TestRoundingDecimalField(TestCase): + def test_valid_rounding(self): + field = serializers.DecimalField(max_digits=4, decimal_places=2, rounding=ROUND_UP) + assert field.to_representation(Decimal('1.234')) == '1.24' + field = serializers.DecimalField(max_digits=4, decimal_places=2, rounding=ROUND_DOWN) + assert field.to_representation(Decimal('1.234')) == '1.23' + + def test_invalid_rounding(self): + with pytest.raises(AssertionError) as excinfo: + serializers.DecimalField(max_digits=1, decimal_places=1, rounding='ROUND_UNKNOWN') + assert 'Invalid rounding option' in str(excinfo.value) + + +# Date & time serializers... class TestDateField(FieldValues): """ Valid and invalid values for `DateField`. From f77e794dc81da078b915a72f2b33e014e2fadb6a Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 6 Nov 2017 01:02:48 -0800 Subject: [PATCH 163/217] Fix all BytesWarning caught during tests (#5561) Running the tests with bytes warning enabled shows some bytes/str mixups. Fix them all. Some examples of mixing usage: str(b'foo') -- calling str() on bytes b'foo' == 'foo' -- compare str with bytes 'foo' + b'bar' -- concatenating str and bytes --- rest_framework/renderers.py | 2 ++ rest_framework/utils/mediatypes.py | 2 +- tests/test_negotiation.py | 6 +----- tests/test_renderers.py | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index a7508bb7c..c63170158 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -567,6 +567,8 @@ class BrowsableAPIRenderer(BaseRenderer): if isinstance(field, serializers.HiddenField): data.pop(name, None) content = renderer.render(data, accepted, context) + # Renders returns bytes, but CharField expects a str. + content = content.decode('utf-8') else: content = None diff --git a/rest_framework/utils/mediatypes.py b/rest_framework/utils/mediatypes.py index 865c283cc..9fe3da05b 100644 --- a/rest_framework/utils/mediatypes.py +++ b/rest_framework/utils/mediatypes.py @@ -83,5 +83,5 @@ class _MediaType(object): def __str__(self): ret = "%s/%s" % (self.main_type, self.sub_type) for key, val in self.params.items(): - ret += "; %s=%s" % (key, val) + ret += "; %s=%s" % (key, val.decode('ascii')) return ret diff --git a/tests/test_negotiation.py b/tests/test_negotiation.py index b435b876a..7ce3f92a9 100644 --- a/tests/test_negotiation.py +++ b/tests/test_negotiation.py @@ -77,11 +77,7 @@ class TestAcceptedMediaType(TestCase): def test_mediatype_string_representation(self): mediatype = _MediaType('test/*; foo=bar') - params_str = '' - for key, val in mediatype.params.items(): - params_str += '; %s=%s' % (key, val) - expected = 'test/*' + params_str - assert str(mediatype) == expected + assert str(mediatype) == 'test/*; foo=bar' def test_raise_error_if_no_suitable_renderers_found(self): class MockRenderer(object): diff --git a/tests/test_renderers.py b/tests/test_renderers.py index 57dc854de..9a2d033e8 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -676,7 +676,7 @@ class AdminRendererTests(TestCase): request = factory.get('/') response = view(request) response.render() - self.assertInHTML('Fooa string', str(response.content)) + self.assertContains(response, 'Fooa string', html=True) def test_render_dict_with_items_key(self): factory = APIRequestFactory() @@ -691,7 +691,7 @@ class AdminRendererTests(TestCase): request = factory.get('/') response = view(request) response.render() - self.assertInHTML('Itemsa string', str(response.content)) + self.assertContains(response, 'Itemsa string', html=True) def test_render_dict_with_iteritems_key(self): factory = APIRequestFactory() @@ -706,7 +706,7 @@ class AdminRendererTests(TestCase): request = factory.get('/') response = view(request) response.render() - self.assertInHTML('Iteritemsa string', str(response.content)) + self.assertContains(response, 'Iteritemsa string', html=True) class TestDocumentationRenderer(TestCase): From 0552810410bd772b35e48c738a1ebc37f67c9255 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 6 Nov 2017 01:03:01 -0800 Subject: [PATCH 164/217] Use dict and set literals instead of calls to dict() and set() (#5559) Set literals are available on all supported Python versions. They are idiomatic and always faster: $ python3 -m timeit '{}' 10000000 loops, best of 3: 0.0357 usec per loop $ python3 -m timeit 'dict()' 10000000 loops, best of 3: 0.104 usec per loop $ python3 -m timeit '{1, 2, 3}' 10000000 loops, best of 3: 0.0754 usec per loop $ python3 -m timeit 'set([1, 2, 3])' 1000000 loops, best of 3: 0.228 usec per loop --- rest_framework/decorators.py | 2 +- rest_framework/schemas/generators.py | 4 ++-- rest_framework/schemas/inspectors.py | 4 ++-- rest_framework/serializers.py | 4 ++-- tests/test_fields.py | 6 +++--- tests/test_multitable_inheritance.py | 4 ++-- tests/test_one_to_one_with_inheritance.py | 2 +- tests/test_renderers.py | 2 +- tests/test_serializer_nested.py | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index cdbd59e99..2f93fdd97 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -46,7 +46,7 @@ def api_view(http_method_names=None, exclude_from_schema=False): assert isinstance(http_method_names, (list, tuple)), \ '@api_view expected a list of strings, received %s' % type(http_method_names).__name__ - allowed_methods = set(http_method_names) | set(('options',)) + allowed_methods = set(http_method_names) | {'options'} WrappedAPIView.http_method_names = [method.lower() for method in allowed_methods] def handler(self, *args, **kwargs): diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 393e21575..b28797b0b 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -118,9 +118,9 @@ def distribute_links(obj): def is_custom_action(action): - return action not in set([ + return action not in { 'retrieve', 'list', 'create', 'update', 'partial_update', 'destroy' - ]) + } def endpoint_ordering(endpoint): diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 101766ba5..f112e5eee 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -385,11 +385,11 @@ class AutoSchema(ViewInspector): view = self.view # Core API supports the following request encodings over HTTP... - supported_media_types = set(( + supported_media_types = { 'application/json', 'application/x-www-form-urlencoded', 'multipart/form-data', - )) + } parser_classes = getattr(view, 'parser_classes', []) for parser_class in parser_classes: media_type = getattr(parser_class, 'media_type', None) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 59533be1e..994d0273f 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -1172,13 +1172,13 @@ class ModelSerializer(Serializer): # Some model fields may introduce kwargs that would not be valid # for the choice field. We need to strip these out. # Eg. models.DecimalField(max_digits=3, decimal_places=1, choices=DECIMAL_CHOICES) - valid_kwargs = set(( + valid_kwargs = { 'read_only', 'write_only', 'required', 'default', 'initial', 'source', 'label', 'help_text', 'style', 'error_messages', 'validators', 'allow_null', 'allow_blank', 'choices' - )) + } for key in list(field_kwargs.keys()): if key not in valid_kwargs: field_kwargs.pop(key) diff --git a/tests/test_fields.py b/tests/test_fields.py index 876dd39c8..ca530d240 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1618,15 +1618,15 @@ class TestMultipleChoiceField(FieldValues): """ valid_inputs = { (): set(), - ('aircon',): set(['aircon']), - ('aircon', 'manual'): set(['aircon', 'manual']), + ('aircon',): {'aircon'}, + ('aircon', 'manual'): {'aircon', 'manual'}, } invalid_inputs = { 'abc': ['Expected a list of items but got type "str".'], ('aircon', 'incorrect'): ['"incorrect" is not a valid choice.'] } outputs = [ - (['aircon', 'manual', 'incorrect'], set(['aircon', 'manual', 'incorrect'])) + (['aircon', 'manual', 'incorrect'], {'aircon', 'manual', 'incorrect'}) ] field = serializers.MultipleChoiceField( choices=[ diff --git a/tests/test_multitable_inheritance.py b/tests/test_multitable_inheritance.py index 2aacbc348..c406fceda 100644 --- a/tests/test_multitable_inheritance.py +++ b/tests/test_multitable_inheritance.py @@ -44,7 +44,7 @@ class InheritedModelSerializationTests(TestCase): """ child = ChildModel(name1='parent name', name2='child name') serializer = DerivedModelSerializer(child) - assert set(serializer.data.keys()) == set(['name1', 'name2', 'id']) + assert set(serializer.data.keys()) == {'name1', 'name2', 'id'} def test_onetoone_primary_key_model_fields_as_expected(self): """ @@ -54,7 +54,7 @@ class InheritedModelSerializationTests(TestCase): parent = ParentModel.objects.create(name1='parent name') associate = AssociatedModel.objects.create(name='hello', ref=parent) serializer = AssociatedModelSerializer(associate) - assert set(serializer.data.keys()) == set(['name', 'ref']) + assert set(serializer.data.keys()) == {'name', 'ref'} def test_data_is_valid_without_parent_ptr(self): """ diff --git a/tests/test_one_to_one_with_inheritance.py b/tests/test_one_to_one_with_inheritance.py index aa527a318..d1a5b826c 100644 --- a/tests/test_one_to_one_with_inheritance.py +++ b/tests/test_one_to_one_with_inheritance.py @@ -41,4 +41,4 @@ class InheritedModelSerializationTests(TestCase): child = ChildModel(name1='parent name', name2='child name') serializer = DerivedModelSerializer(child) self.assertEqual(set(serializer.data.keys()), - set(['name1', 'name2', 'id', 'childassociatedmodel'])) + {'name1', 'name2', 'id', 'childassociatedmodel'}) diff --git a/tests/test_renderers.py b/tests/test_renderers.py index 9a2d033e8..54b3ce964 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -316,7 +316,7 @@ class JSONRendererTests(TestCase): def test_render_dict_abc_obj(self): class Dict(MutableMapping): def __init__(self): - self._dict = dict() + self._dict = {} def __getitem__(self, key): return self._dict.__getitem__(key) diff --git a/tests/test_serializer_nested.py b/tests/test_serializer_nested.py index efb671918..09b8dd105 100644 --- a/tests/test_serializer_nested.py +++ b/tests/test_serializer_nested.py @@ -194,11 +194,11 @@ class TestNestedSerializerWithList: serializer = self.Serializer(data=input_data) assert serializer.is_valid() - assert serializer.validated_data['nested']['example'] == set([1, 2]) + assert serializer.validated_data['nested']['example'] == {1, 2} def test_nested_serializer_with_list_multipart(self): input_data = QueryDict('nested.example=1&nested.example=2') serializer = self.Serializer(data=input_data) assert serializer.is_valid() - assert serializer.validated_data['nested']['example'] == set([1, 2]) + assert serializer.validated_data['nested']['example'] == {1, 2} From d49d796c85c89c3641ebcbd68d99da0bed1c8039 Mon Sep 17 00:00:00 2001 From: Sergei Azarkin Date: Mon, 6 Nov 2017 13:14:37 +0300 Subject: [PATCH 165/217] Change ImageField validation pattern, use validators from DjangoImageField (#5539) --- rest_framework/fields.py | 3 +-- tests/test_fields.py | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index dd852f3c6..55c2fe48e 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1553,8 +1553,7 @@ class ImageField(FileField): file_object = super(ImageField, self).to_internal_value(data) django_field = self._DjangoImageField() django_field.error_messages = self.error_messages - django_field.to_python(file_object) - return file_object + return django_field.clean(file_object) # Composite field types... diff --git a/tests/test_fields.py b/tests/test_fields.py index ca530d240..101d3b26d 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -14,7 +14,7 @@ from django.utils.timezone import activate, deactivate, utc import rest_framework from rest_framework import compat, serializers -from rest_framework.fields import is_simple_callable +from rest_framework.fields import DjangoImageField, is_simple_callable try: import pytz @@ -1714,15 +1714,24 @@ class TestFieldFieldWithName(FieldValues): field = serializers.FileField(use_url=False) +def ext_validator(value): + if not value.name.endswith('.png'): + raise serializers.ValidationError('File extension is not allowed. Allowed extensions is png.') + + # Stub out mock Django `forms.ImageField` class so we don't *actually* # call into it's regular validation, or require PIL for testing. -class FailImageValidation(object): +class PassImageValidation(DjangoImageField): + default_validators = [ext_validator] + def to_python(self, value): - raise serializers.ValidationError(self.error_messages['invalid_image']) + return value -class PassImageValidation(object): +class FailImageValidation(PassImageValidation): def to_python(self, value): + if value.name == 'badimage.png': + raise serializers.ValidationError(self.error_messages['invalid_image']) return value @@ -1732,7 +1741,8 @@ class TestInvalidImageField(FieldValues): """ valid_inputs = {} invalid_inputs = [ - (MockFile(name='example.txt', size=10), ['Upload a valid image. The file you uploaded was either not an image or a corrupted image.']) + (MockFile(name='badimage.png', size=10), ['Upload a valid image. The file you uploaded was either not an image or a corrupted image.']), + (MockFile(name='goodimage.html', size=10), ['File extension is not allowed. Allowed extensions is png.']) ] outputs = {} field = serializers.ImageField(_DjangoImageField=FailImageValidation) @@ -1743,7 +1753,7 @@ class TestValidImageField(FieldValues): Values for an valid `ImageField`. """ valid_inputs = [ - (MockFile(name='example.txt', size=10), MockFile(name='example.txt', size=10)) + (MockFile(name='example.png', size=10), MockFile(name='example.png', size=10)) ] invalid_inputs = {} outputs = {} From 7a278b3540fc9319a30f4bec5f3e10b826b7b0b8 Mon Sep 17 00:00:00 2001 From: Yuri Nikulin Date: Mon, 6 Nov 2017 13:46:37 +0300 Subject: [PATCH 166/217] fix processing unicode symbols in query_string by Python 2 (#5552) * fix processing unicode symbols in query_string by Python 2 * Add comments for encoded test strings. * Add file encoding for Python 2. --- rest_framework/utils/urls.py | 7 ++-- tests/test_utils.py | 65 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/rest_framework/utils/urls.py b/rest_framework/utils/urls.py index e7b3b29f4..3766928d4 100644 --- a/rest_framework/utils/urls.py +++ b/rest_framework/utils/urls.py @@ -1,3 +1,4 @@ +from django.utils.encoding import force_str from django.utils.six.moves.urllib import parse as urlparse @@ -6,9 +7,9 @@ def replace_query_param(url, key, val): Given a URL and a key/val pair, set or replace an item in the query parameters of the URL, and return the new URL. """ - (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url) + (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url)) query_dict = urlparse.parse_qs(query, keep_blank_values=True) - query_dict[key] = [val] + query_dict[force_str(key)] = [force_str(val)] query = urlparse.urlencode(sorted(list(query_dict.items())), doseq=True) return urlparse.urlunsplit((scheme, netloc, path, query, fragment)) @@ -18,7 +19,7 @@ def remove_query_param(url, key): Given a URL and a key/val pair, remove an item in the query parameters of the URL, and return the new URL. """ - (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url) + (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url)) query_dict = urlparse.parse_qs(query, keep_blank_values=True) query_dict.pop(key, None) query = urlparse.urlencode(sorted(list(query_dict.items())), doseq=True) diff --git a/tests/test_utils.py b/tests/test_utils.py index c5e6f26dc..4aed5ee73 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf.urls import url @@ -11,6 +12,7 @@ from rest_framework.routers import SimpleRouter from rest_framework.serializers import ModelSerializer from rest_framework.utils import json from rest_framework.utils.breadcrumbs import get_breadcrumbs +from rest_framework.utils.urls import remove_query_param, replace_query_param from rest_framework.views import APIView from rest_framework.viewsets import ModelViewSet from tests.models import BasicModel @@ -205,3 +207,66 @@ class NonStrictJsonFloatTests(JsonFloatTests): """ 'STRICT_JSON = False' should not somehow affect internal json behavior """ + + +class UrlsReplaceQueryParamTests(TestCase): + """ + Tests the replace_query_param functionality. + """ + def test_valid_unicode_preserved(self): + # Encoded string: '查询' + q = '/?q=%E6%9F%A5%E8%AF%A2' + new_key = 'page' + new_value = 2 + value = '%E6%9F%A5%E8%AF%A2' + + assert new_key in replace_query_param(q, new_key, new_value) + assert value in replace_query_param(q, new_key, new_value) + + def test_valid_unicode_replaced(self): + q = '/?page=1' + value = '1' + new_key = 'q' + new_value = '%E6%9F%A5%E8%AF%A2' + + assert new_key in replace_query_param(q, new_key, new_value) + assert value in replace_query_param(q, new_key, new_value) + + def test_invalid_unicode(self): + # Encoded string: '��=1' + q = '/e/?%FF%FE%3C%73%63%72%69%70%74%3E%61%6C%65%72%74%28%33%31%33%29%3C%2F%73%63%72%69%70%74%3E=1' + key = 'from' + value = 'login' + + assert key in replace_query_param(q, key, value) + + +class UrlsRemoveQueryParamTests(TestCase): + """ + Tests the remove_query_param functionality. + """ + def test_valid_unicode_preserved(self): + q = '/?q=%E6%9F%A5%E8%AF%A2' + new_key = 'page' + new_value = 2 + value = '%E6%9F%A5%E8%AF%A2' + + assert new_key in replace_query_param(q, new_key, new_value) + assert value in replace_query_param(q, new_key, new_value) + + def test_valid_unicode_removed(self): + q = '/?page=2345&q=%E6%9F%A5%E8%AF%A2' + key = 'page' + value = '2345' + removed_key = 'q' + + assert key in remove_query_param(q, removed_key) + assert value in remove_query_param(q, removed_key) + assert '%' not in remove_query_param(q, removed_key) + + def test_invalid_unicode(self): + q = '/?from=login&page=2&%FF%FE%3C%73%63%72%69%70%74%3E%61%6C%65%72%74%28%33%31%33%29%3C%2F%73%63%72%69%70%74%3E=1' + key = 'from' + removed_key = 'page' + + assert key in remove_query_param(q, removed_key) From 3dc40f9572b651da8b59f55dc6a948540eae16f5 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 6 Nov 2017 12:05:08 +0100 Subject: [PATCH 167/217] Version 3.7.2 Release (#5563) * Begin release notes for 3.7.2 * Add release notes fro merged issues. * Finalise release notes * Increment version number to 3.7.2 * Update translations --- docs/topics/release-notes.md | 63 ++++++++++++++++++ rest_framework/__init__.py | 2 +- .../locale/ar/LC_MESSAGES/django.mo | Bin 5766 -> 6566 bytes .../locale/ar/LC_MESSAGES/django.po | 25 +++---- .../locale/nb/LC_MESSAGES/django.mo | Bin 9803 -> 9803 bytes .../locale/nb/LC_MESSAGES/django.po | 7 +- 6 files changed, 81 insertions(+), 16 deletions(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 7549d6964..fe8cb5331 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -41,6 +41,39 @@ You can determine your currently installed version using `pip freeze`: ## 3.7.x series +### 3.7.2 + +**Date**: [6th Novemember 2017][3.7.2-milestone] + +* Fixed Django 2.1 compatibility due to removal of django.contrib.auth.login()/logout() views. [#5510][gh5510] +* Add missing import for TextLexer. [#5512][gh5512] +* Adding examples and documentation for caching [#5514][gh5514] +* Include date and date-time format for schema generation [#5511][gh5511] +* Use triple backticks for markdown code blocks [#5513][gh5513] +* Interactive docs - make bottom sidebar items sticky [#5516][gh5516] +* Clarify pagination system check [#5524][gh5524] +* Stop JSONBoundField mangling invalid JSON [#5527][gh5527] +* Have JSONField render as textarea in Browsable API [#5530][gh5530] +* Schema: Exclude OPTIONS/HEAD for ViewSet actions [#5532][gh5532] +* Fix ordering for dotted sources [#5533][gh5533] +* Fix: Fields with `allow_null=True` should imply a default serialization value [#5518][gh5518] +* Ensure Location header is strictly a 'str', not subclass. [#5544][gh5544] +* Add import to example in api-guide/parsers [#5547][gh5547] +* Catch OverflowError for "out of range" datetimes [#5546][gh5546] +* Add djangorestframework-rapidjson to third party packages [#5549][gh5549] +* Increase test coverage for `drf_create_token` command [#5550][gh5550] +* Add trove classifier for Python 3.6 support. [#5555][gh5555] +* Add pip cache support to the Travis CI configuration [#5556][gh5556] +* Rename [`wheel`] section to [`bdist_wheel`] as the former is legacy [#5557][gh5557] +* Fix invalid escape sequence deprecation warnings [#5560][gh5560] +* Add interactive docs error template [#5548][gh5548] +* Add rounding parameter to DecimalField [#5562][gh5562] +* Fix all BytesWarning caught during tests [#5561][gh5561] +* Use dict and set literals instead of calls to dict() and set() [#5559][gh5559] +* Change ImageField validation pattern, use validators from DjangoImageField [#5539][gh5539] +* Fix processing unicode symbols in query_string by Python 2 [#5552][gh5552] + + ### 3.7.1 **Date**: [16th October 2017][3.7.1-milestone] @@ -821,6 +854,7 @@ For older release notes, [please see the version 2.x documentation][old-release- [3.6.4-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.6.4+Release%22 [3.7.0-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.7.0+Release%22 [3.7.1-milestone]: https://github.com/encode/django-rest-framework/milestone/58?closed=1 +[3.7.2-milestone]: https://github.com/encode/django-rest-framework/milestone/59?closed=1 @@ -1547,3 +1581,32 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh5503]: https://github.com/encode/django-rest-framework/issues/5503 [gh5500]: https://github.com/encode/django-rest-framework/issues/5500 [gh5492]: https://github.com/encode/django-rest-framework/issues/5492 + + +[gh5552]: https://github.com/encode/django-rest-framework/issues/5552 +[gh5539]: https://github.com/encode/django-rest-framework/issues/5539 +[gh5559]: https://github.com/encode/django-rest-framework/issues/5559 +[gh5561]: https://github.com/encode/django-rest-framework/issues/5561 +[gh5562]: https://github.com/encode/django-rest-framework/issues/5562 +[gh5548]: https://github.com/encode/django-rest-framework/issues/5548 +[gh5560]: https://github.com/encode/django-rest-framework/issues/5560 +[gh5557]: https://github.com/encode/django-rest-framework/issues/5557 +[gh5556]: https://github.com/encode/django-rest-framework/issues/5556 +[gh5555]: https://github.com/encode/django-rest-framework/issues/5555 +[gh5550]: https://github.com/encode/django-rest-framework/issues/5550 +[gh5549]: https://github.com/encode/django-rest-framework/issues/5549 +[gh5546]: https://github.com/encode/django-rest-framework/issues/5546 +[gh5547]: https://github.com/encode/django-rest-framework/issues/5547 +[gh5544]: https://github.com/encode/django-rest-framework/issues/5544 +[gh5518]: https://github.com/encode/django-rest-framework/issues/5518 +[gh5533]: https://github.com/encode/django-rest-framework/issues/5533 +[gh5532]: https://github.com/encode/django-rest-framework/issues/5532 +[gh5530]: https://github.com/encode/django-rest-framework/issues/5530 +[gh5527]: https://github.com/encode/django-rest-framework/issues/5527 +[gh5524]: https://github.com/encode/django-rest-framework/issues/5524 +[gh5516]: https://github.com/encode/django-rest-framework/issues/5516 +[gh5513]: https://github.com/encode/django-rest-framework/issues/5513 +[gh5511]: https://github.com/encode/django-rest-framework/issues/5511 +[gh5514]: https://github.com/encode/django-rest-framework/issues/5514 +[gh5512]: https://github.com/encode/django-rest-framework/issues/5512 +[gh5510]: https://github.com/encode/django-rest-framework/issues/5510 diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py index 45845e2e9..2507bb14e 100644 --- a/rest_framework/__init__.py +++ b/rest_framework/__init__.py @@ -8,7 +8,7 @@ ______ _____ _____ _____ __ """ __title__ = 'Django REST framework' -__version__ = '3.7.1' +__version__ = '3.7.2' __author__ = 'Tom Christie' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2011-2017 Tom Christie' diff --git a/rest_framework/locale/ar/LC_MESSAGES/django.mo b/rest_framework/locale/ar/LC_MESSAGES/django.mo index bda2ce995f0a4ecdd7f4f3dfe1260c3af1a10a34..73d87ba67aedd232548dbf054d50995471c0ff0a 100644 GIT binary patch delta 2050 zcmZ|PUu+ab9Ki9pw$MM&77A2_D$|0k*!Jj^e{Dh9S_KK17^E0dHQ90pG`6?oZjXPZ z*0%OffW(Be8WNQdkT!)<&l3pvpl`ew#3yG>ROE>eO-y_>#_w-$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t))}Pz-io!Pp}pP{F)1_9`o=7>VdtOi}#R^c^u~9^Yr)#hB^O<6Vc6La#(>n z--OC-FD~Huwx3QR16@cmb`zD!ZRBH*(hi{}@&cKoy-Vw(CiV%Z;-B<+!T3~VBB%*$ z#R@!vs>pTBZA_dH1I!;eph1}b=VkPcIF13ru$Ko7H0%o^x0q4UL z%+}#Ibg_)GMQ{@?#IqQiLg!xki|42Z{J;zN8!zK2>ZYa1n#8)|PE-chum=;^fYHfj ztMCqLNk>piSsY9yvIm)qwc!$s1*yL_&m#tQ;cHY0OQ^GMRE_%n1ZwTB;1=x1x%dNf zFqofOnqt&-VN_zPQ5D>Us&FeR!FH^`SU&YHrt_GAdVGt@ETG zB}9l|-pNvG!_FqO94hH(BXQ$ZHwu<)+Nf%JQ?xm?to)BCx72$qwRS4cXq!(bOsJ&s zeVIkx_RI~A_jzom6YtKN6aSU$1Fn#EyS_Lk_e, 2017 # aymen chaieb , 2017 # Bashar Al-Abdulhadi, 2016-2017 -# Eyad Toma , 2015 +# Eyad Toma , 2015,2017 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2017-08-15 17:08+0000\n" -"Last-Translator: aymen chaieb \n" +"PO-Revision-Date: 2017-10-18 09:51+0000\n" +"Last-Translator: Andrew Ayoub \n" "Language-Team: Arabic (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/ar/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -127,7 +128,7 @@ msgstr "غير موجود." #: exceptions.py:109 msgid "Method \"{method}\" not allowed." -msgstr "" +msgstr "طلب غير مسموح به" #: exceptions.py:120 msgid "Could not satisfy the request Accept header." @@ -190,7 +191,7 @@ msgstr "" #: fields.py:796 msgid "Enter a valid IPv4 or IPv6 address." -msgstr "" +msgstr "برجاء إدخال عنوان IPV4 أو IPV6 صحيح" #: fields.py:821 msgid "A valid integer is required." @@ -206,7 +207,7 @@ msgstr "تأكد ان القيمة أكبر أو تساوي {min_value}." #: fields.py:824 fields.py:859 fields.py:896 msgid "String value too large." -msgstr "" +msgstr "القيمه اكبر من المسموح" #: fields.py:856 fields.py:890 msgid "A valid number is required." @@ -233,7 +234,7 @@ msgstr "صيغة التاريخ و الوقت غير صحيحة. عليك أن #: fields.py:1026 msgid "Expected a datetime but got a date." -msgstr "" +msgstr "متوقع تاريخ و وقت و وجد تاريخ فقط" #: fields.py:1103 msgid "Date has wrong format. Use one of these formats instead: {format}." @@ -241,7 +242,7 @@ msgstr "صيغة التاريخ غير صحيحة. عليك أن تستخدم و #: fields.py:1104 msgid "Expected a date but got a datetime." -msgstr "" +msgstr "متوقع تاريخ فقط و وجد تاريخ ووقت" #: fields.py:1170 msgid "Time has wrong format. Use one of these formats instead: {format}." @@ -249,7 +250,7 @@ msgstr "صيغة الوقت غير صحيحة. عليك أن تستخدم واح #: fields.py:1232 msgid "Duration has wrong format. Use one of these formats instead: {format}." -msgstr "" +msgstr "صيغة المده غير صحيحه, برجاء إستخدام أحد هذه الصيغ {format}" #: fields.py:1251 fields.py:1300 msgid "\"{input}\" is not a valid choice." @@ -257,7 +258,7 @@ msgstr "\"{input}\" ليست واحدة من الخيارات الصالحة." #: fields.py:1254 relations.py:71 relations.py:441 msgid "More than {count} items..." -msgstr "" +msgstr "أكثر من {count} عنصر..." #: fields.py:1301 fields.py:1448 relations.py:437 serializers.py:524 msgid "Expected a list of items but got type \"{input_type}\"." @@ -399,7 +400,7 @@ msgstr "" #: validators.py:43 msgid "This field must be unique." -msgstr "هذا الحقل يجب أن يكون وحيد" +msgstr "هذا الحقل يجب أن يكون فريد" #: validators.py:97 msgid "The fields {field_names} must make a unique set." @@ -439,4 +440,4 @@ msgstr "" #: views.py:88 msgid "Permission denied." -msgstr "حق غير مصرح به" +msgstr "ليس لديك صلاحية." diff --git a/rest_framework/locale/nb/LC_MESSAGES/django.mo b/rest_framework/locale/nb/LC_MESSAGES/django.mo index d942abc2cfb380462f026a8dbfa09219dbc7b2dd..18cc4bc8d98712a02b5ee5832dafdd3b7001880f 100644 GIT binary patch delta 60 zcmX@@bJ}M^tQd!(p{{|Uf`R4aR53+Kr=rr*JO!JQjQrfhV!b2~&mlcGF*9fLd@&b} O$?s&?H@}igWCs9jI~6Vf delta 59 zcmX@@bJ}M^tQd!Zg|30If}zReR53+K=ZvDv;*!i%1)GxmTn8Xdh6-$+FXqC*lv%R* IsazU609dyarvLx| diff --git a/rest_framework/locale/nb/LC_MESSAGES/django.po b/rest_framework/locale/nb/LC_MESSAGES/django.po index f9ecada63..27bbdbe18 100644 --- a/rest_framework/locale/nb/LC_MESSAGES/django.po +++ b/rest_framework/locale/nb/LC_MESSAGES/django.po @@ -4,13 +4,14 @@ # # Translators: # Petter Kjelkenes , 2015 +# Thomas Bruun , 2017 msgid "" msgstr "" "Project-Id-Version: Django REST framework\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-07-12 16:13+0100\n" -"PO-Revision-Date: 2017-08-03 14:58+0000\n" -"Last-Translator: Thomas Christie \n" +"PO-Revision-Date: 2017-11-01 09:58+0000\n" +"Last-Translator: Thomas Bruun \n" "Language-Team: Norwegian Bokmål (http://www.transifex.com/django-rest-framework-1/django-rest-framework/language/nb/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -363,7 +364,7 @@ msgstr "Ugyldig verdi." #: serializers.py:326 msgid "Invalid data. Expected a dictionary, but got {datatype}." -msgstr "Ugyldige data. Forventet en dicitonary, men fikk {datatype}." +msgstr "Ugyldige data. Forventet en dictionary, men fikk {datatype}." #: templates/rest_framework/admin.html:116 #: templates/rest_framework/base.html:128 From d4d9cc1d53fa38fdf6b38e2a64b4aa3a71a9760c Mon Sep 17 00:00:00 2001 From: Xavier Ordoquy Date: Mon, 6 Nov 2017 15:06:47 +0100 Subject: [PATCH 168/217] Move django.contrib.auth import out of compat. Fixed some regressions where compat was imported during app loading and led to importing django.contrib.auth.models which ended in a `AppRegistryNotReady` exception. --- rest_framework/compat.py | 9 --------- rest_framework/urls.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index ce821402e..456c8b20d 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -11,7 +11,6 @@ import inspect import django from django.apps import apps from django.conf import settings -from django.contrib.auth import views from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.validators import \ MaxLengthValidator as DjangoMaxLengthValidator @@ -334,11 +333,3 @@ def authenticate(request=None, **credentials): else: return authenticate(request=request, **credentials) -if django.VERSION < (1, 11): - login = views.login - login_kwargs = {'template_name': 'rest_framework/login.html'} - logout = views.logout -else: - login = views.LoginView.as_view(template_name='rest_framework/login.html') - login_kwargs = {} - logout = views.LogoutView.as_view() diff --git a/rest_framework/urls.py b/rest_framework/urls.py index 60107d4d2..1ab5fad61 100644 --- a/rest_framework/urls.py +++ b/rest_framework/urls.py @@ -15,8 +15,17 @@ and you should make sure your authentication settings include `SessionAuthentica from __future__ import unicode_literals from django.conf.urls import url +from django.contrib.auth import views + +if django.VERSION < (1, 11): + login = views.login + login_kwargs = {'template_name': 'rest_framework/login.html'} + logout = views.logout +else: + login = views.LoginView.as_view(template_name='rest_framework/login.html') + login_kwargs = {} + logout = views.LogoutView.as_view() -from rest_framework.compat import login, login_kwargs, logout app_name = 'rest_framework' urlpatterns = [ From 7d0fa02dc05ec9f1f398e870066ae8d2c717d5de Mon Sep 17 00:00:00 2001 From: Xavier Ordoquy Date: Mon, 6 Nov 2017 15:23:54 +0100 Subject: [PATCH 169/217] Revert "Move django.contrib.auth import out of compat." This reverts commit d4d9cc1d53fa38fdf6b38e2a64b4aa3a71a9760c. --- rest_framework/compat.py | 9 +++++++++ rest_framework/urls.py | 11 +---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 456c8b20d..ce821402e 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -11,6 +11,7 @@ import inspect import django from django.apps import apps from django.conf import settings +from django.contrib.auth import views from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.validators import \ MaxLengthValidator as DjangoMaxLengthValidator @@ -333,3 +334,11 @@ def authenticate(request=None, **credentials): else: return authenticate(request=request, **credentials) +if django.VERSION < (1, 11): + login = views.login + login_kwargs = {'template_name': 'rest_framework/login.html'} + logout = views.logout +else: + login = views.LoginView.as_view(template_name='rest_framework/login.html') + login_kwargs = {} + logout = views.LogoutView.as_view() diff --git a/rest_framework/urls.py b/rest_framework/urls.py index 1ab5fad61..60107d4d2 100644 --- a/rest_framework/urls.py +++ b/rest_framework/urls.py @@ -15,17 +15,8 @@ and you should make sure your authentication settings include `SessionAuthentica from __future__ import unicode_literals from django.conf.urls import url -from django.contrib.auth import views - -if django.VERSION < (1, 11): - login = views.login - login_kwargs = {'template_name': 'rest_framework/login.html'} - logout = views.logout -else: - login = views.LoginView.as_view(template_name='rest_framework/login.html') - login_kwargs = {} - logout = views.LogoutView.as_view() +from rest_framework.compat import login, login_kwargs, logout app_name = 'rest_framework' urlpatterns = [ From ca341ef70576967c6ebe243a079bbd31d1631a9e Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 6 Nov 2017 09:56:57 -0500 Subject: [PATCH 170/217] Add compat import test --- tests/conftest.py | 1 + tests/importable/__init__.py | 2 ++ tests/importable/test_installed.py | 13 +++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/importable/__init__.py create mode 100644 tests/importable/test_installed.py diff --git a/tests/conftest.py b/tests/conftest.py index 0e5c55ffe..9906935d7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -41,6 +41,7 @@ def pytest_configure(): 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', + 'tests.importable', 'tests', ), PASSWORD_HASHERS=( diff --git a/tests/importable/__init__.py b/tests/importable/__init__.py new file mode 100644 index 000000000..19aaf6f90 --- /dev/null +++ b/tests/importable/__init__.py @@ -0,0 +1,2 @@ + +from rest_framework import compat # noqa diff --git a/tests/importable/test_installed.py b/tests/importable/test_installed.py new file mode 100644 index 000000000..5998c9cbc --- /dev/null +++ b/tests/importable/test_installed.py @@ -0,0 +1,13 @@ + +from django.conf import settings +from tests import importable + + +def test_installed(): + # ensure that apps can freely import rest_framework.compat + assert 'tests.importable' in settings.INSTALLED_APPS + + +def test_imported(): + # ensure that the __init__ hasn't been mucked with + assert hasattr(importable, 'compat') From d6a8e020219a5c1a543b2b1c68de58ac03386b1d Mon Sep 17 00:00:00 2001 From: Xavier Ordoquy Date: Mon, 6 Nov 2017 15:06:47 +0100 Subject: [PATCH 171/217] Move django.contrib.auth import out of compat. Fixed some regressions where compat was imported during app loading and led to importing django.contrib.auth.models which ended in a `AppRegistryNotReady` exception. --- rest_framework/compat.py | 9 --------- rest_framework/urls.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index ce821402e..456c8b20d 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -11,7 +11,6 @@ import inspect import django from django.apps import apps from django.conf import settings -from django.contrib.auth import views from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.validators import \ MaxLengthValidator as DjangoMaxLengthValidator @@ -334,11 +333,3 @@ def authenticate(request=None, **credentials): else: return authenticate(request=request, **credentials) -if django.VERSION < (1, 11): - login = views.login - login_kwargs = {'template_name': 'rest_framework/login.html'} - logout = views.logout -else: - login = views.LoginView.as_view(template_name='rest_framework/login.html') - login_kwargs = {} - logout = views.LogoutView.as_view() diff --git a/rest_framework/urls.py b/rest_framework/urls.py index 60107d4d2..10cc5def0 100644 --- a/rest_framework/urls.py +++ b/rest_framework/urls.py @@ -14,9 +14,19 @@ and you should make sure your authentication settings include `SessionAuthentica """ from __future__ import unicode_literals +import django from django.conf.urls import url +from django.contrib.auth import views + +if django.VERSION < (1, 11): + login = views.login + login_kwargs = {'template_name': 'rest_framework/login.html'} + logout = views.logout +else: + login = views.LoginView.as_view(template_name='rest_framework/login.html') + login_kwargs = {} + logout = views.LogoutView.as_view() -from rest_framework.compat import login, login_kwargs, logout app_name = 'rest_framework' urlpatterns = [ From 0f33e63e10f23b9af243480a0eb002be3e98159b Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 6 Nov 2017 16:32:12 +0100 Subject: [PATCH 172/217] Update version and release notes for v3.7.3 (#5568) --- docs/topics/release-notes.md | 11 +++++++++++ rest_framework/__init__.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index fe8cb5331..9ac3ab100 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -41,6 +41,13 @@ You can determine your currently installed version using `pip freeze`: ## 3.7.x series +### 3.7.3 + +**Date**: [6th Novemember 2017][3.7.3-milestone] + +* Fix `AppRegistryNotReady` error from contrib.auth view imports [#5567][gh5567] + + ### 3.7.2 **Date**: [6th Novemember 2017][3.7.2-milestone] @@ -855,6 +862,7 @@ For older release notes, [please see the version 2.x documentation][old-release- [3.7.0-milestone]: https://github.com/encode/django-rest-framework/issues?q=milestone%3A%223.7.0+Release%22 [3.7.1-milestone]: https://github.com/encode/django-rest-framework/milestone/58?closed=1 [3.7.2-milestone]: https://github.com/encode/django-rest-framework/milestone/59?closed=1 +[3.7.3-milestone]: https://github.com/encode/django-rest-framework/milestone/60?closed=1 @@ -1610,3 +1618,6 @@ For older release notes, [please see the version 2.x documentation][old-release- [gh5514]: https://github.com/encode/django-rest-framework/issues/5514 [gh5512]: https://github.com/encode/django-rest-framework/issues/5512 [gh5510]: https://github.com/encode/django-rest-framework/issues/5510 + + +[gh5567]: https://github.com/encode/django-rest-framework/issues/5567 diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py index 2507bb14e..e1e55c612 100644 --- a/rest_framework/__init__.py +++ b/rest_framework/__init__.py @@ -8,7 +8,7 @@ ______ _____ _____ _____ __ """ __title__ = 'Django REST framework' -__version__ = '3.7.2' +__version__ = '3.7.3' __author__ = 'Tom Christie' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2011-2017 Tom Christie' From ea810001602bbf8fa615097abffa372a0b29a4f7 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 8 Nov 2017 21:30:33 -0800 Subject: [PATCH 173/217] Remove ulrparse compatability shim; use six instead The urlparse shim in compat.py duplicates Django's bundled six. Can rely on upstream instead of duplicating their works. Unifies shim with other files already using six. --- rest_framework/compat.py | 6 ------ rest_framework/schemas/inspectors.py | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 456c8b20d..03cae2187 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -54,12 +54,6 @@ def make_url_resolver(regex, urlpatterns): return RegexURLResolver(regex, urlpatterns) -try: - import urlparse # Python 2.x -except ImportError: - import urllib.parse as urlparse - - def unicode_repr(instance): # Get the repr of an instance, but ensure it is a unicode string # on both python 3 (already the case) and 2 (not the case). diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index f112e5eee..bae4d38ed 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -9,10 +9,11 @@ from collections import OrderedDict from django.db import models from django.utils.encoding import force_text, smart_text +from django.utils.six.moves.urllib import parse as urlparse from django.utils.translation import ugettext_lazy as _ from rest_framework import exceptions, serializers -from rest_framework.compat import coreapi, coreschema, uritemplate, urlparse +from rest_framework.compat import coreapi, coreschema, uritemplate from rest_framework.settings import api_settings from rest_framework.utils import formatting From f8e8381c009bc9c8651037eb130e57ab7daee5bf Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 9 Nov 2017 00:03:48 -0800 Subject: [PATCH 174/217] Drop compat wrapper for TimeDelta.total_seconds() (#5577) TimeDelta.total_seconds() was introduced in Python 2.7 and 3.2. It is available on all supported Python versions. https://docs.python.org/2/library/datetime.html#datetime.timedelta.total_seconds https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds --- rest_framework/compat.py | 8 -------- rest_framework/utils/encoders.py | 4 ++-- tests/test_compat.py | 9 --------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 03cae2187..67531948e 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -78,14 +78,6 @@ def unicode_http_header(value): return value -def total_seconds(timedelta): - # TimeDelta.total_seconds() is only available in Python 2.7 - if hasattr(timedelta, 'total_seconds'): - return timedelta.total_seconds() - else: - return (timedelta.days * 86400.0) + float(timedelta.seconds) + (timedelta.microseconds / 1000000.0) - - def distinct(queryset, base): if settings.DATABASES[queryset.db]["ENGINE"] == "django.db.backends.oracle": # distinct analogue for Oracle users diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 87df365e0..7518d4ffd 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -13,7 +13,7 @@ from django.utils import six, timezone from django.utils.encoding import force_text from django.utils.functional import Promise -from rest_framework.compat import coreapi, total_seconds +from rest_framework.compat import coreapi class JSONEncoder(json.JSONEncoder): @@ -39,7 +39,7 @@ class JSONEncoder(json.JSONEncoder): representation = obj.isoformat() return representation elif isinstance(obj, datetime.timedelta): - return six.text_type(total_seconds(obj)) + return six.text_type(obj.total_seconds()) elif isinstance(obj, decimal.Decimal): # Serializers will coerce decimals to strings by default. return float(obj) diff --git a/tests/test_compat.py b/tests/test_compat.py index aa1107617..842cb8ef8 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -13,15 +13,6 @@ class CompatTests(TestCase): compat.django.VERSION = self.original_django_version compat.transaction = self.original_transaction - def test_total_seconds(self): - class MockTimedelta(object): - days = 1 - seconds = 1 - microseconds = 100 - timedelta = MockTimedelta() - expected = (timedelta.days * 86400.0) + float(timedelta.seconds) + (timedelta.microseconds / 1000000.0) - assert compat.total_seconds(timedelta) == expected - def test_set_rollback_for_transaction_in_managed_mode(self): class MockTransaction(object): called_rollback = False From f9c67f04d408365704cbb98590cc7348a9f07120 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 9 Nov 2017 11:57:53 -0800 Subject: [PATCH 175/217] Clean up all whitespace throughout project (#5578) * Remove trailing whitespace from lines * Remove trailing nad leading whitespace from files Allows for cleaner diffs in future changes. For editors that automatically clean up whitespace on save, will avoid unrelated line changes in diffs. --- .editorconfig | 7 +++++++ .gitignore | 1 + .tx/config | 1 - docs/api-guide/caching.md | 8 ++++---- docs/api-guide/generic-views.md | 6 +++--- docs/api-guide/permissions.md | 6 +++--- docs/api-guide/routers.md | 12 ++++++------ docs/api-guide/schemas.md | 1 - docs/api-guide/validators.md | 2 +- docs/topics/3.7-announcement.md | 1 - docs/topics/browser-enhancements.md | 2 +- docs/topics/html-and-forms.md | 4 ++-- docs/topics/jobs.md | 2 +- rest_framework/compat.py | 1 - rest_framework/static/rest_framework/css/default.css | 1 - .../docs/fonts/fontawesome-webfont.svg | 2 +- .../docs/fonts/glyphicons-halflings-regular.svg | 2 +- .../fonts/glyphicons-halflings-regular.svg | 2 +- .../templates/rest_framework/docs/error.html | 4 ---- .../rest_framework/docs/langs/javascript-intro.html | 1 - tests/importable/__init__.py | 1 - tests/importable/test_installed.py | 1 - 22 files changed, 32 insertions(+), 36 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..f999431de --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index 41768084c..70b55a094 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ MANIFEST coverage.* +!.editorconfig !.gitignore !.travis.yml !.isort.cfg diff --git a/.tx/config b/.tx/config index dea9db7c9..e151a7e6f 100644 --- a/.tx/config +++ b/.tx/config @@ -7,4 +7,3 @@ file_filter = rest_framework/locale//LC_MESSAGES/django.po source_file = rest_framework/locale/en_US/LC_MESSAGES/django.po source_lang = en_US type = PO - diff --git a/docs/api-guide/caching.md b/docs/api-guide/caching.md index 289b5a2b2..ed3f62c21 100644 --- a/docs/api-guide/caching.md +++ b/docs/api-guide/caching.md @@ -1,6 +1,6 @@ # Caching -> A certain woman had a very sharp conciousness but almost no +> A certain woman had a very sharp conciousness but almost no > memory ... She remembered enough to work, and she worked hard. > - Lydia Davis @@ -22,9 +22,9 @@ from rest_framework.views import APIView from rest_framework import viewsets class UserViewSet(viewsets.Viewset): - + # Cache requested url for each user for 2 hours - @method_decorator(cache_page(60*60*2)) + @method_decorator(cache_page(60*60*2)) @method_decorator(vary_on_cookie) def list(self, request, format=None): content = { @@ -35,7 +35,7 @@ class UserViewSet(viewsets.Viewset): class PostView(APIView): # Cache page for the requested url - @method_decorator(cache_page(60*60*2)) + @method_decorator(cache_page(60*60*2)) def get(self, request, format=None): content = { 'title': 'Post title', diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index 381f1fe73..a0ed7bdea 100644 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -113,11 +113,11 @@ For example: Note that if your API doesn't include any object level permissions, you may optionally exclude the `self.check_object_permissions`, and simply return the object from the `get_object_or_404` lookup. -#### `filter_queryset(self, queryset)` +#### `filter_queryset(self, queryset)` -Given a queryset, filter it with whichever filter backends are in use, returning a new queryset. +Given a queryset, filter it with whichever filter backends are in use, returning a new queryset. -For example: +For example: def filter_queryset(self, queryset): filter_backends = (CategoryFilter,) diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md index ef9ce3abd..3b89e9141 100644 --- a/docs/api-guide/permissions.md +++ b/docs/api-guide/permissions.md @@ -197,15 +197,15 @@ If you need to test if a request is a read operation or a write operation, you s --- Custom permissions will raise a `PermissionDenied` exception if the test fails. To change the error message associated with the exception, implement a `message` attribute directly on your custom permission. Otherwise the `default_detail` attribute from `PermissionDenied` will be used. - + from rest_framework import permissions class CustomerAccessPermission(permissions.BasePermission): message = 'Adding customers not allowed.' - + def has_permission(self, request, view): ... - + ## Examples The following is an example of a permission class that checks the incoming request's IP address against a blacklist, and denies the request if the IP has been blacklisted. diff --git a/docs/api-guide/routers.md b/docs/api-guide/routers.md index 0c6aab152..84ca82a3f 100644 --- a/docs/api-guide/routers.md +++ b/docs/api-guide/routers.md @@ -58,11 +58,11 @@ For example, you can append `router.urls` to a list of existing views… router = routers.SimpleRouter() router.register(r'users', UserViewSet) router.register(r'accounts', AccountViewSet) - + urlpatterns = [ url(r'^forgot-password/$', ForgotPasswordFormView.as_view()), ] - + urlpatterns += router.urls Alternatively you can use Django's `include` function, like so… @@ -106,10 +106,10 @@ For example, if you want to change the URL for our custom action to `^users/{pk} from myapp.permissions import IsAdminOrIsSelf from rest_framework.decorators import detail_route - + class UserViewSet(ModelViewSet): ... - + @detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf], url_path='change-password') def set_password(self, request, pk=None): ... @@ -124,10 +124,10 @@ For example, if you want to change the name of our custom action to `'user-chang from myapp.permissions import IsAdminOrIsSelf from rest_framework.decorators import detail_route - + class UserViewSet(ModelViewSet): ... - + @detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf], url_name='change-password') def set_password(self, request, pk=None): ... diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 29b779d50..22894a978 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -784,4 +784,3 @@ in [OpenAPI][open-api] format. [api-blueprint]: https://apiblueprint.org/ [static-files]: https://docs.djangoproject.com/en/stable/howto/static-files/ [named-arguments]: https://docs.djangoproject.com/en/stable/topics/http/urls/#named-groups - \ No newline at end of file diff --git a/docs/api-guide/validators.md b/docs/api-guide/validators.md index 0e58c6fff..fe492c0a7 100644 --- a/docs/api-guide/validators.md +++ b/docs/api-guide/validators.md @@ -84,7 +84,7 @@ It has two required arguments, and a single optional `messages` argument: The validator should be applied to *serializer classes*, like so: from rest_framework.validators import UniqueTogetherValidator - + class ExampleSerializer(serializers.Serializer): # ... class Meta: diff --git a/docs/topics/3.7-announcement.md b/docs/topics/3.7-announcement.md index 709580a4b..a916f67b4 100644 --- a/docs/topics/3.7-announcement.md +++ b/docs/topics/3.7-announcement.md @@ -1,4 +1,3 @@ - {% endif %} {% endblock %} {% endblock %} From 15024f3f07b9311887ad6f5afb366f6c032c0486 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Tue, 14 Nov 2017 03:55:59 -0500 Subject: [PATCH 180/217] Remove set_rollback() from compat (#5591) * Remove Django 1.6 transaction compat * Move set_rollback from compat => views --- rest_framework/compat.py | 21 ++----------------- rest_framework/views.py | 9 ++++++-- tests/test_compat.py | 44 ---------------------------------------- 3 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 tests/test_compat.py diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 75a840ad5..5009ffee1 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -12,7 +12,7 @@ from django.apps import apps from django.conf import settings from django.core import validators from django.core.exceptions import ImproperlyConfigured -from django.db import connection, models, transaction +from django.db import models from django.utils import six from django.views.generic import View @@ -250,7 +250,7 @@ else: # pytz is required from Django 1.11. Remove when dropping Django 1.10 support. try: - import pytz # noqa + import pytz # noqa from pytz.exceptions import InvalidTimeError except ImportError: InvalidTimeError = Exception @@ -297,23 +297,6 @@ class MaxLengthValidator(CustomValidatorMessage, validators.MaxLengthValidator): pass -def set_rollback(): - if hasattr(transaction, 'set_rollback'): - if connection.settings_dict.get('ATOMIC_REQUESTS', False): - # If running in >=1.6 then mark a rollback as required, - # and allow it to be handled by Django. - if connection.in_atomic_block: - transaction.set_rollback(True) - elif transaction.is_managed(): - # Otherwise handle it explicitly if in managed mode. - if transaction.is_dirty(): - transaction.rollback() - transaction.leave_transaction_management() - else: - # transaction not managed - pass - - def authenticate(request=None, **credentials): from django.contrib.auth import authenticate if django.VERSION < (1, 11): diff --git a/rest_framework/views.py b/rest_framework/views.py index dfed15888..3140bb9a3 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals from django.conf import settings from django.core.exceptions import PermissionDenied -from django.db import models +from django.db import connection, models, transaction from django.http import Http404 from django.http.response import HttpResponseBase from django.utils import six @@ -16,7 +16,6 @@ from django.views.decorators.csrf import csrf_exempt from django.views.generic import View from rest_framework import exceptions, status -from rest_framework.compat import set_rollback from rest_framework.request import Request from rest_framework.response import Response from rest_framework.schemas import AutoSchema @@ -55,6 +54,12 @@ def get_view_description(view_cls, html=False): return description +def set_rollback(): + atomic_requests = connection.settings_dict.get('ATOMIC_REQUESTS', False) + if atomic_requests and connection.in_atomic_block: + transaction.set_rollback(True) + + def exception_handler(exc, context): """ Returns the response that should be used for any given exception. diff --git a/tests/test_compat.py b/tests/test_compat.py deleted file mode 100644 index 842cb8ef8..000000000 --- a/tests/test_compat.py +++ /dev/null @@ -1,44 +0,0 @@ -from django.test import TestCase - -from rest_framework import compat - - -class CompatTests(TestCase): - - def setUp(self): - self.original_django_version = compat.django.VERSION - self.original_transaction = compat.transaction - - def tearDown(self): - compat.django.VERSION = self.original_django_version - compat.transaction = self.original_transaction - - def test_set_rollback_for_transaction_in_managed_mode(self): - class MockTransaction(object): - called_rollback = False - called_leave_transaction_management = False - - def is_managed(self): - return True - - def is_dirty(self): - return True - - def rollback(self): - self.called_rollback = True - - def leave_transaction_management(self): - self.called_leave_transaction_management = True - - dirty_mock_transaction = MockTransaction() - compat.transaction = dirty_mock_transaction - compat.set_rollback() - assert dirty_mock_transaction.called_rollback is True - assert dirty_mock_transaction.called_leave_transaction_management is True - - clean_mock_transaction = MockTransaction() - clean_mock_transaction.is_dirty = lambda: False - compat.transaction = clean_mock_transaction - compat.set_rollback() - assert clean_mock_transaction.called_rollback is False - assert clean_mock_transaction.called_leave_transaction_management is True From 9f66e8baddd9d8106a121b159356422086e7d90c Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 15 Nov 2017 14:58:37 -0500 Subject: [PATCH 181/217] Fix request body/POST access (#5590) * Modernize middleware tests * Added a failing test for #5582 * Set data ref on underlying django request --- rest_framework/request.py | 5 ++-- tests/test_middleware.py | 60 +++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/rest_framework/request.py b/rest_framework/request.py index 4f413e03f..f9503cd59 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -250,9 +250,10 @@ class Request(object): else: self._full_data = self._data - # copy files refs to the underlying request so that closable + # copy data & files refs to the underlying request so that closable # objects are handled appropriately. - self._request._files = self._files + self._request._post = self.POST + self._request._files = self.FILES def _load_stream(self): """ diff --git a/tests/test_middleware.py b/tests/test_middleware.py index a9f620c0e..9df7d8e3e 100644 --- a/tests/test_middleware.py +++ b/tests/test_middleware.py @@ -1,34 +1,76 @@ from django.conf.urls import url from django.contrib.auth.models import User +from django.http import HttpRequest from django.test import override_settings from rest_framework.authentication import TokenAuthentication from rest_framework.authtoken.models import Token +from rest_framework.request import is_form_media_type +from rest_framework.response import Response from rest_framework.test import APITestCase from rest_framework.views import APIView + +class PostView(APIView): + def post(self, request): + return Response(data=request.data, status=200) + + urlpatterns = [ - url(r'^$', APIView.as_view(authentication_classes=(TokenAuthentication,))), + url(r'^auth$', APIView.as_view(authentication_classes=(TokenAuthentication,))), + url(r'^post$', PostView.as_view()), ] -class MyMiddleware(object): +class RequestUserMiddleware(object): + def __init__(self, get_response): + self.get_response = get_response - def process_response(self, request, response): + def __call__(self, request): + response = self.get_response(request) assert hasattr(request, 'user'), '`user` is not set on request' - assert request.user.is_authenticated(), '`user` is not authenticated' + assert request.user.is_authenticated, '`user` is not authenticated' + + return response + + +class RequestPOSTMiddleware(object): + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + assert isinstance(request, HttpRequest) + + # Parse body with underlying Django request + request.body + + # Process request with DRF view + response = self.get_response(request) + + # Ensure request.POST is set as appropriate + if is_form_media_type(request.content_type): + assert request.POST == {'foo': ['bar']} + else: + assert request.POST == {} + return response @override_settings(ROOT_URLCONF='tests.test_middleware') class TestMiddleware(APITestCase): + + @override_settings(MIDDLEWARE=('tests.test_middleware.RequestUserMiddleware',)) def test_middleware_can_access_user_when_processing_response(self): user = User.objects.create_user('john', 'john@example.com', 'password') key = 'abcd1234' Token.objects.create(key=key, user=user) - with self.settings( - MIDDLEWARE_CLASSES=('tests.test_middleware.MyMiddleware',) - ): - auth = 'Token ' + key - self.client.get('/', HTTP_AUTHORIZATION=auth) + self.client.get('/auth', HTTP_AUTHORIZATION='Token %s' % key) + + @override_settings(MIDDLEWARE=('tests.test_middleware.RequestPOSTMiddleware',)) + def test_middleware_can_access_request_post_when_processing_response(self): + response = self.client.post('/post', {'foo': 'bar'}) + assert response.status_code == 200 + + response = self.client.post('/post', {'foo': 'bar'}, format='json') + assert response.status_code == 200 From 25319984274e799ab557dc96a2f6563d4d2c07a7 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 20 Nov 2017 02:58:29 -0500 Subject: [PATCH 182/217] Rename test to reference correct issue (#5610) --- tests/test_serializer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_serializer.py b/tests/test_serializer.py index df8839356..23c6ec2c1 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -515,7 +515,7 @@ class TestSerializerValidationWithCompiledRegexField: assert serializer.errors == {} -class Test2505Regression: +class Test2555Regression: def test_serializer_context(self): class NestedSerializer(serializers.Serializer): def __init__(self, *args, **kwargs): From 20954469b2938f2e701f11e0398815c557bafa67 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Mon, 20 Nov 2017 21:07:36 +1300 Subject: [PATCH 183/217] Fix in documentation (#5611) - model serializers now must provide either "fields" or "exclude" as attribute --- docs/api-guide/serializers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 0e235c88d..021ef1c38 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -493,6 +493,8 @@ The names in the `fields` and `exclude` attributes will normally map to model fi Alternatively names in the `fields` options can map to properties or methods which take no arguments that exist on the model class. +Since version 3.3.0, it is **mandatory** to provide one of the attributes `fields` or `exclude`. + ## Specifying nested serialization The default `ModelSerializer` uses primary keys for relationships, but you can also easily generate nested representations using the `depth` option: From 9c11077cf63283fcebb939d58202d4841c942eb8 Mon Sep 17 00:00:00 2001 From: bartkim0426 Date: Mon, 20 Nov 2017 17:08:16 +0900 Subject: [PATCH 184/217] Fix in documentation (#5612) - typo in serialization document: 'intead' => 'instead' --- docs/api-guide/serializers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 021ef1c38..ee6e41607 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -1011,7 +1011,7 @@ Takes the object instance that requires serialization, and should return a primi Takes the unvalidated incoming data as input and should return the validated data that will be made available as `serializer.validated_data`. The return value will also be passed to the `.create()` or `.update()` methods if `.save()` is called on the serializer class. -If any of the validation fails, then the method should raise a `serializers.ValidationError(errors)`. The `errors` argument should be a dictionary mapping field names (or `settings.NON_FIELD_ERRORS_KEY`) to a list of error messages. If you don't need to alter deserialization behavior and instead want to provide object-level validation, it's recommended that you intead override the [`.validate()`](#object-level-validation) method. +If any of the validation fails, then the method should raise a `serializers.ValidationError(errors)`. The `errors` argument should be a dictionary mapping field names (or `settings.NON_FIELD_ERRORS_KEY`) to a list of error messages. If you don't need to alter deserialization behavior and instead want to provide object-level validation, it's recommended that you instead override the [`.validate()`](#object-level-validation) method. The `data` argument passed to this method will normally be the value of `request.data`, so the datatype it provides will depend on the parser classes you have configured for your API. From ff556a91fdd62b389b9b0b6c353d2161263346bc Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 20 Nov 2017 00:35:54 -0800 Subject: [PATCH 185/217] Remove references to unsupported Django versions in docs and code (#5602) Per the trove classifiers, DRF only supports Django versions 1.10+. Can drop documentation, code comments, and workarounds for older Django versions. --- docs/api-guide/fields.md | 4 +--- docs/index.md | 4 ++-- docs/tutorial/1-serialization.md | 2 -- docs/tutorial/4-authentication-and-permissions.md | 5 ++--- rest_framework/authtoken/serializers.py | 12 ++++-------- rest_framework/renderers.py | 2 +- rest_framework/urls.py | 5 ++--- rest_framework/utils/model_meta.py | 10 ++-------- tests/test_atomic_requests.py | 5 ++--- tests/test_fields.py | 6 ------ tests/test_filters.py | 3 --- 11 files changed, 16 insertions(+), 42 deletions(-) diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 64014b56e..d209a945b 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -356,8 +356,6 @@ Corresponds to `django.db.models.fields.DurationField` The `validated_data` for these fields will contain a `datetime.timedelta` instance. The representation is a string following this format `'[DD] [HH:[MM:]]ss[.uuuuuu]'`. -**Note:** This field is only available with Django versions >= 1.8. - **Signature:** `DurationField()` --- @@ -681,4 +679,4 @@ The [django-rest-framework-hstore][django-rest-framework-hstore] package provide [django-rest-framework-gis]: https://github.com/djangonauts/django-rest-framework-gis [django-rest-framework-hstore]: https://github.com/djangonauts/django-rest-framework-hstore [django-hstore]: https://github.com/djangonauts/django-hstore -[python-decimal-rounding-modes]: https://docs.python.org/3/library/decimal.html#rounding-modes \ No newline at end of file +[python-decimal-rounding-modes]: https://docs.python.org/3/library/decimal.html#rounding-modes diff --git a/docs/index.md b/docs/index.md index a902ed3af..0e747463b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -120,10 +120,10 @@ If you're intending to use the browsable API you'll probably also want to add RE urlpatterns = [ ... - url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) + url(r'^api-auth/', include('rest_framework.urls')) ] -Note that the URL path can be whatever you want, but you must include `'rest_framework.urls'` with the `'rest_framework'` namespace. You may leave out the namespace in Django 1.9+, and REST framework will set it for you. +Note that the URL path can be whatever you want. ## Example diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md index 558797816..a834c8dbb 100644 --- a/docs/tutorial/1-serialization.md +++ b/docs/tutorial/1-serialization.md @@ -48,8 +48,6 @@ We'll need to add our new `snippets` app and the `rest_framework` app to `INSTAL 'snippets.apps.SnippetsConfig', ) -Please note that if you're using Django <1.9, you need to replace `snippets.apps.SnippetsConfig` with `snippets`. - Okay, we're ready to roll. ## Creating a model to work with diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md index b43fabfac..72cf64e37 100644 --- a/docs/tutorial/4-authentication-and-permissions.md +++ b/docs/tutorial/4-authentication-and-permissions.md @@ -142,11 +142,10 @@ Add the following import at the top of the file: And, at the end of the file, add a pattern to include the login and logout views for the browsable API. urlpatterns += [ - url(r'^api-auth/', include('rest_framework.urls', - namespace='rest_framework')), + url(r'^api-auth/', include('rest_framework.urls'), ] -The `r'^api-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. In Django 1.9+, REST framework will set the namespace, so you may leave it out. +The `r'^api-auth/'` part of pattern can actually be whatever URL you want to use. Now if you open up the browser again and refresh the page you'll see a 'Login' link in the top right of the page. If you log in as one of the users you created earlier, you'll be able to create code snippets again. diff --git a/rest_framework/authtoken/serializers.py b/rest_framework/authtoken/serializers.py index 301b6a0cb..01d2d40b9 100644 --- a/rest_framework/authtoken/serializers.py +++ b/rest_framework/authtoken/serializers.py @@ -20,14 +20,10 @@ class AuthTokenSerializer(serializers.Serializer): user = authenticate(request=self.context.get('request'), username=username, password=password) - if user: - # From Django 1.10 onwards the `authenticate` call simply - # returns `None` for is_active=False users. - # (Assuming the default `ModelBackend` authentication backend.) - if not user.is_active: - msg = _('User account is disabled.') - raise serializers.ValidationError(msg, code='authorization') - else: + # The authenticate call simply returns None for is_active=False + # users. (Assuming the default ModelBackend authentication + # backend.) + if not user: msg = _('Unable to log in with provided credentials.') raise serializers.ValidationError(msg, code='authorization') else: diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 3298294ce..bbefb4624 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -666,7 +666,7 @@ class BrowsableAPIRenderer(BaseRenderer): paginator = None csrf_cookie_name = settings.CSRF_COOKIE_NAME - csrf_header_name = getattr(settings, 'CSRF_HEADER_NAME', 'HTTP_X_CSRFToken') # Fallback for Django 1.8 + csrf_header_name = settings.CSRF_HEADER_NAME if csrf_header_name.startswith('HTTP_'): csrf_header_name = csrf_header_name[5:] csrf_header_name = csrf_header_name.replace('_', '-') diff --git a/rest_framework/urls.py b/rest_framework/urls.py index 10cc5def0..80fce5dc4 100644 --- a/rest_framework/urls.py +++ b/rest_framework/urls.py @@ -6,11 +6,10 @@ your API requires authentication: urlpatterns = [ ... - url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')) + url(r'^auth/', include('rest_framework.urls')) ] -In Django versions older than 1.9, the urls must be namespaced as 'rest_framework', -and you should make sure your authentication settings include `SessionAuthentication`. +You should make sure your authentication settings include `SessionAuthentication`. """ from __future__ import unicode_literals diff --git a/rest_framework/utils/model_meta.py b/rest_framework/utils/model_meta.py index f0ae02bb2..4cc93b8ef 100644 --- a/rest_framework/utils/model_meta.py +++ b/rest_framework/utils/model_meta.py @@ -105,18 +105,13 @@ def _get_reverse_relationships(opts): """ Returns an `OrderedDict` of field names to `RelationInfo`. """ - # Note that we have a hack here to handle internal API differences for - # this internal API across Django 1.7 -> Django 1.8. - # See: https://code.djangoproject.com/ticket/24208 - reverse_relations = OrderedDict() all_related_objects = [r for r in opts.related_objects if not r.field.many_to_many] for relation in all_related_objects: accessor_name = relation.get_accessor_name() - related = getattr(relation, 'related_model', relation.model) reverse_relations[accessor_name] = RelationInfo( model_field=None, - related_model=related, + related_model=relation.related_model, to_many=relation.field.remote_field.multiple, to_field=_get_to_field(relation.field), has_through_model=False, @@ -127,10 +122,9 @@ def _get_reverse_relationships(opts): all_related_many_to_many_objects = [r for r in opts.related_objects if r.field.many_to_many] for relation in all_related_many_to_many_objects: accessor_name = relation.get_accessor_name() - related = getattr(relation, 'related_model', relation.model) reverse_relations[accessor_name] = RelationInfo( model_field=None, - related_model=related, + related_model=relation.related_model, to_many=True, # manytomany do not have to_fields to_field=None, diff --git a/tests/test_atomic_requests.py b/tests/test_atomic_requests.py index f925ce3d3..697c549de 100644 --- a/tests/test_atomic_requests.py +++ b/tests/test_atomic_requests.py @@ -120,13 +120,12 @@ class DBTransactionAPIExceptionTests(TestCase): Transaction is rollbacked by our transaction atomic block. """ request = factory.post('/') - num_queries = (4 if getattr(connection.features, - 'can_release_savepoints', False) else 3) + num_queries = 4 if connection.features.can_release_savepoints else 3 with self.assertNumQueries(num_queries): # 1 - begin savepoint # 2 - insert # 3 - rollback savepoint - # 4 - release savepoint (django>=1.8 only) + # 4 - release savepoint with transaction.atomic(): response = self.view(request) assert transaction.get_rollback() diff --git a/tests/test_fields.py b/tests/test_fields.py index 101d3b26d..fc9ce192a 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -5,7 +5,6 @@ import unittest import uuid from decimal import ROUND_DOWN, ROUND_UP, Decimal -import django import pytest from django.http import QueryDict from django.test import TestCase, override_settings @@ -1197,11 +1196,6 @@ class TestDateTimeField(FieldValues): field = serializers.DateTimeField(default_timezone=utc) -if django.VERSION[:2] <= (1, 8): - # Doesn't raise an error on earlier versions of Django - TestDateTimeField.invalid_inputs.pop('2018-08-16 22:00-24:00') - - class TestCustomInputFormatDateTimeField(FieldValues): """ Valid and invalid values for `DateTimeField` with a custom input format. diff --git a/tests/test_filters.py b/tests/test_filters.py index 970f6bdfc..f9e068fec 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,9 +1,7 @@ from __future__ import unicode_literals import datetime -import unittest -import django import pytest from django.core.exceptions import ImproperlyConfigured from django.db import models @@ -291,7 +289,6 @@ class SearchFilterToManyTests(TestCase): Entry.objects.create(blog=b2, headline='Something unrelated', pub_date=datetime.date(1979, 1, 1)) Entry.objects.create(blog=b2, headline='Retrospective on Lennon', pub_date=datetime.date(1990, 6, 1)) - @unittest.skipIf(django.VERSION < (1, 9), "Django 1.8 does not support transforms") def test_multiple_filter_conditions(self): class SearchListView(generics.ListAPIView): queryset = Blog.objects.all() From a3df1c119967e04fd57495ebbb4645b02883fc4e Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 20 Nov 2017 03:51:16 -0500 Subject: [PATCH 186/217] Test Serializer exclude for declared fields (#5599) * Test current behavior of exclude+declared field * Assert declared fields are not present in exclude --- rest_framework/serializers.py | 11 +++++++++++ tests/test_model_serializer.py | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 994d0273f..0952e190c 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -1102,6 +1102,17 @@ class ModelSerializer(Serializer): if exclude is not None: # If `Meta.exclude` is included, then remove those fields. for field_name in exclude: + assert field_name not in self._declared_fields, ( + "Cannot both declare the field '{field_name}' and include " + "it in the {serializer_class} 'exclude' option. Remove the " + "field or, if inherited from a parent serializer, disable " + "with `{field_name} = None`." + .format( + field_name=field_name, + serializer_class=self.__class__.__name__ + ) + ) + assert field_name in fields, ( "The field '{field_name}' was included on serializer " "{serializer_class} in the 'exclude' option, but does " diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index 203e1fe7f..98586b971 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -900,6 +900,22 @@ class TestSerializerMetaClass(TestCase): "Cannot set both 'fields' and 'exclude' options on serializer ExampleSerializer." ) + def test_declared_fields_with_exclude_option(self): + class ExampleSerializer(serializers.ModelSerializer): + text = serializers.CharField() + + class Meta: + model = MetaClassTestModel + exclude = ('text',) + + expected = ( + "Cannot both declare the field 'text' and include it in the " + "ExampleSerializer 'exclude' option. Remove the field or, if " + "inherited from a parent serializer, disable with `text = None`." + ) + with self.assertRaisesMessage(AssertionError, expected): + ExampleSerializer().fields + class Issue2704TestCase(TestCase): def test_queryset_all(self): From 134a6f66f92dc4e6ae390f166c6cead8a8d8c13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bielawski?= Date: Wed, 22 Nov 2017 05:11:59 +0000 Subject: [PATCH 187/217] Fixed schema generation for filter backends (#5613) --- rest_framework/schemas/inspectors.py | 2 +- tests/test_schemas.py | 48 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index bae4d38ed..80dc49268 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -368,7 +368,7 @@ class AutoSchema(ViewInspector): if hasattr(self.view, 'action'): return self.view.action in ["list", "retrieve", "update", "partial_update", "destroy"] - return method.lower in ["get", "put", "patch", "delete"] + return method.lower() in ["get", "put", "patch", "delete"] def get_filter_fields(self, path, method): if not self._allows_filters(path, method): diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 1a84dfc89..56692d4f5 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -951,3 +951,51 @@ def test_head_and_options_methods_are_excluded(): assert inspector.should_include_endpoint(path, callback) assert inspector.get_allowed_methods(callback) == ["GET"] + + +class TestAutoSchemaAllowsFilters(object): + class MockAPIView(APIView): + filter_backends = [filters.OrderingFilter] + + def _test(self, method): + view = self.MockAPIView() + fields = view.schema.get_filter_fields('', method) + field_names = [f.name for f in fields] + + return 'ordering' in field_names + + def test_get(self): + assert self._test('get') + + def test_GET(self): + assert self._test('GET') + + def test_put(self): + assert self._test('put') + + def test_PUT(self): + assert self._test('PUT') + + def test_patch(self): + assert self._test('patch') + + def test_PATCH(self): + assert self._test('PATCH') + + def test_delete(self): + assert self._test('delete') + + def test_DELETE(self): + assert self._test('DELETE') + + def test_post(self): + assert not self._test('post') + + def test_POST(self): + assert not self._test('POST') + + def test_foo(self): + assert not self._test('foo') + + def test_FOO(self): + assert not self._test('FOO') From ae88f5c55bc8d7b273e0619354120c5c8f17202e Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 22 Nov 2017 04:36:34 -0500 Subject: [PATCH 188/217] Minor cleanup for ModelSerializer tests (#5598) * Replace assertRaises with assertRaisesMessage * Remove outdated implicit Meta.fields test * Simplify parent declared field test --- tests/test_model_serializer.py | 69 ++++++++-------------------------- 1 file changed, 16 insertions(+), 53 deletions(-) diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index 98586b971..c2c7fb61e 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -123,10 +123,10 @@ class TestModelSerializer(TestCase): 'non_model_field': 'bar', }) serializer.is_valid() - with self.assertRaises(TypeError) as excinfo: - serializer.save() + msginitial = 'Got a `TypeError` when calling `OneFieldModel.objects.create()`.' - assert str(excinfo.exception).startswith(msginitial) + with self.assertRaisesMessage(TypeError, msginitial): + serializer.save() def test_abstract_model(self): """ @@ -147,10 +147,10 @@ class TestModelSerializer(TestCase): serializer = TestSerializer(data={ 'afield': 'foo', }) - with self.assertRaises(ValueError) as excinfo: - serializer.is_valid() + msginitial = 'Cannot use ModelSerializer with Abstract Models.' - assert str(excinfo.exception).startswith(msginitial) + with self.assertRaisesMessage(ValueError, msginitial): + serializer.is_valid() class TestRegularFieldMappings(TestCase): @@ -294,10 +294,9 @@ class TestRegularFieldMappings(TestCase): model = RegularFieldsModel fields = ('auto_field', 'invalid') - with self.assertRaises(ImproperlyConfigured) as excinfo: - TestSerializer().fields expected = 'Field name `invalid` is not valid for model `RegularFieldsModel`.' - assert str(excinfo.exception) == expected + with self.assertRaisesMessage(ImproperlyConfigured, expected): + TestSerializer().fields def test_missing_field(self): """ @@ -311,13 +310,12 @@ class TestRegularFieldMappings(TestCase): model = RegularFieldsModel fields = ('auto_field',) - with self.assertRaises(AssertionError) as excinfo: - TestSerializer().fields expected = ( "The field 'missing' was declared on serializer TestSerializer, " "but has not been included in the 'fields' option." ) - assert str(excinfo.exception) == expected + with self.assertRaisesMessage(AssertionError, expected): + TestSerializer().fields def test_missing_superclass_field(self): """ @@ -327,13 +325,7 @@ class TestRegularFieldMappings(TestCase): class TestSerializer(serializers.ModelSerializer): missing = serializers.ReadOnlyField() - class Meta: - model = RegularFieldsModel - fields = '__all__' - class ChildSerializer(TestSerializer): - missing = serializers.ReadOnlyField() - class Meta: model = RegularFieldsModel fields = ('auto_field',) @@ -348,22 +340,6 @@ class TestRegularFieldMappings(TestCase): ExampleSerializer() - def test_fields_and_exclude_behavior(self): - class ImplicitFieldsSerializer(serializers.ModelSerializer): - class Meta: - model = RegularFieldsModel - fields = '__all__' - - class ExplicitFieldsSerializer(serializers.ModelSerializer): - class Meta: - model = RegularFieldsModel - fields = '__all__' - - implicit = ImplicitFieldsSerializer() - explicit = ExplicitFieldsSerializer() - - assert implicit.data == explicit.data - class TestDurationFieldMapping(TestCase): def test_duration_field(self): @@ -862,28 +838,20 @@ class TestSerializerMetaClass(TestCase): model = MetaClassTestModel fields = 'text' - with self.assertRaises(TypeError) as result: + msginitial = "The `fields` option must be a list or tuple" + with self.assertRaisesMessage(TypeError, msginitial): ExampleSerializer().fields - exception = result.exception - assert str(exception).startswith( - "The `fields` option must be a list or tuple" - ) - def test_meta_class_exclude_option(self): class ExampleSerializer(serializers.ModelSerializer): class Meta: model = MetaClassTestModel exclude = 'text' - with self.assertRaises(TypeError) as result: + msginitial = "The `exclude` option must be a list or tuple" + with self.assertRaisesMessage(TypeError, msginitial): ExampleSerializer().fields - exception = result.exception - assert str(exception).startswith( - "The `exclude` option must be a list or tuple" - ) - def test_meta_class_fields_and_exclude_options(self): class ExampleSerializer(serializers.ModelSerializer): class Meta: @@ -891,15 +859,10 @@ class TestSerializerMetaClass(TestCase): fields = ('text',) exclude = ('text',) - with self.assertRaises(AssertionError) as result: + msginitial = "Cannot set both 'fields' and 'exclude' options on serializer ExampleSerializer." + with self.assertRaisesMessage(AssertionError, msginitial): ExampleSerializer().fields - exception = result.exception - self.assertEqual( - str(exception), - "Cannot set both 'fields' and 'exclude' options on serializer ExampleSerializer." - ) - def test_declared_fields_with_exclude_option(self): class ExampleSerializer(serializers.ModelSerializer): text = serializers.CharField() From 1a667f420d9f78f2a9189763981bf65b8e967fb3 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 22 Nov 2017 05:42:59 -0500 Subject: [PATCH 189/217] Reimplement request attribute access w/ __getattr__ (#5617) * Add tests for proxying WSGIRequest attributes in Request. * Add request attribute exception test * Reimplement request attribute access --- rest_framework/request.py | 12 +++--------- tests/test_request.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/rest_framework/request.py b/rest_framework/request.py index f9503cd59..944691039 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -10,8 +10,6 @@ The wrapped request then offers a richer API, in particular : """ from __future__ import unicode_literals -import sys - from django.conf import settings from django.http import QueryDict from django.http.multipartparser import parse_header @@ -373,19 +371,15 @@ class Request(object): else: self.auth = None - def __getattribute__(self, attr): + def __getattr__(self, attr): """ If an attribute does not exist on this instance, then we also attempt to proxy it to the underlying HttpRequest object. """ try: - return super(Request, self).__getattribute__(attr) + return getattr(self._request, attr) except AttributeError: - info = sys.exc_info() - try: - return getattr(self._request, attr) - except AttributeError: - six.reraise(info[0], info[1], info[2].tb_next) + return self.__getattribute__(attr) @property def DATA(self): diff --git a/tests/test_request.py b/tests/test_request.py index a87060df1..cbadb1467 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -249,3 +249,26 @@ class TestSecure(TestCase): def test_default_secure_true(self): request = Request(factory.get('/', secure=True)) assert request.scheme == 'https' + + +class TestWSGIRequestProxy(TestCase): + def test_attribute_access(self): + wsgi_request = factory.get('/') + request = Request(wsgi_request) + + inner_sentinel = object() + wsgi_request.inner_property = inner_sentinel + assert request.inner_property is inner_sentinel + + outer_sentinel = object() + request.inner_property = outer_sentinel + assert request.inner_property is outer_sentinel + + def test_exception(self): + # ensure the exception message is not for the underlying WSGIRequest + wsgi_request = factory.get('/') + request = Request(wsgi_request) + + message = "'Request' object has no attribute 'inner_property'" + with self.assertRaisesMessage(AttributeError, message): + request.inner_property From d71bd57b645190cf3edb8772f8886272c30c2a6b Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Wed, 22 Nov 2017 15:47:03 +0100 Subject: [PATCH 190/217] SchemaJSRenderer renders invalid Javascript (#5607) * SchemaJSRenderer renders invalid Javascript Under Py3 the base64.b64encode() method returns a binary object, which gets rendered as `b'...'` in schema.js. This results in the output becoming: var coreJSON = window.atob('b'eyJf...''); which is invalid Javascript. Because base64 only uses ASCII characters it is safe to decode('ascii') it. Under Py2 this will result in a unicode object, which is fine. Under Py3 it results in a string, which is also fine. This solves the problem and results in a working schema.js output. * Add regression test for #5608 * Add regression test for #5608 * Apparently the linter on Travis wants the imports in a different order than on my box... --- rest_framework/renderers.py | 2 +- tests/test_renderers.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index bbefb4624..80a22dee5 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -852,7 +852,7 @@ class SchemaJSRenderer(BaseRenderer): def render(self, data, accepted_media_type=None, renderer_context=None): codec = coreapi.codecs.CoreJSONCodec() - schema = base64.b64encode(codec.encode(data)) + schema = base64.b64encode(codec.encode(data)).decode('ascii') template = loader.get_template(self.template) context = {'schema': mark_safe(schema)} diff --git a/tests/test_renderers.py b/tests/test_renderers.py index 54b3ce964..ba8400c06 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -18,7 +18,7 @@ import coreapi from rest_framework import permissions, serializers, status from rest_framework.renderers import ( AdminRenderer, BaseRenderer, BrowsableAPIRenderer, DocumentationRenderer, - HTMLFormRenderer, JSONRenderer, StaticHTMLRenderer + HTMLFormRenderer, JSONRenderer, SchemaJSRenderer, StaticHTMLRenderer ) from rest_framework.request import Request from rest_framework.response import Response @@ -736,3 +736,20 @@ class TestDocumentationRenderer(TestCase): html = renderer.render(document, accepted_media_type="text/html", renderer_context={"request": request}) assert '

      Data Endpoint API

      ' in html + + +class TestSchemaJSRenderer(TestCase): + + def test_schemajs_output(self): + """ + Test output of the SchemaJS renderer as per #5608. Django 2.0 on Py3 prints binary data as b'xyz' in templates, + and the base64 encoding used by SchemaJSRenderer outputs base64 as binary. Test fix. + """ + factory = APIRequestFactory() + request = factory.get('/') + + renderer = SchemaJSRenderer() + + output = renderer.render('data', renderer_context={"request": request}) + assert "'ImRhdGEi'" in output + assert "'b'ImRhdGEi''" not in output From 1922dc6e73ecc926a1cd5b0972691e186d614ed3 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 22 Nov 2017 23:16:07 -0500 Subject: [PATCH 191/217] Update Django to 2.0rc1 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 7b78c0ba3..e2c7c2feb 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ setenv = deps = django110: Django>=1.10,<1.11 django111: Django>=1.11,<2.0 - django20: Django>=2.0b1,<2.1 + django20: Django>=2.0rc1,<2.1 djangomaster: https://github.com/django/django/archive/master.tar.gz -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt From bc28b0c74f435a2c9e3a724d552f32845cfb9c70 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 22 Nov 2017 23:16:23 -0500 Subject: [PATCH 192/217] Remove django 2.0 from allowable failures in CI --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 05309cd97..9c9ad7a4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ matrix: allow_failures: - env: DJANGO=master - - env: DJANGO=2.0 install: - pip install tox tox-travis From 7a533cd8b8be156824ca8b1a8a1d540019ba4642 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 22 Nov 2017 23:21:00 -0500 Subject: [PATCH 193/217] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 350174555..ceac9e57c 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ There is a live example API for testing purposes, [available here][sandbox]. # Requirements * Python (2.7, 3.4, 3.5, 3.6) -* Django (1.10, 1.11, 2.0 alpha) +* Django (1.10, 1.11, 2.0rc1) # Installation From a91361dd2fb9e7705a925e52e26b71ffcb13bb30 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Thu, 23 Nov 2017 02:57:31 -0500 Subject: [PATCH 194/217] Perform type check on passed request argument (#5618) * Add test for wrapped request instance * Add 'request' argument type check to Request init * Fix metadata tests' request object --- rest_framework/request.py | 8 +++++++- tests/test_metadata.py | 3 +-- tests/test_request.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/rest_framework/request.py b/rest_framework/request.py index 944691039..5c9cb6136 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -11,7 +11,7 @@ The wrapped request then offers a richer API, in particular : from __future__ import unicode_literals from django.conf import settings -from django.http import QueryDict +from django.http import HttpRequest, QueryDict from django.http.multipartparser import parse_header from django.http.request import RawPostDataException from django.utils import six @@ -132,6 +132,12 @@ class Request(object): def __init__(self, request, parsers=None, authenticators=None, negotiator=None, parser_context=None): + assert isinstance(request, HttpRequest), ( + 'The `request` argument must be an instance of ' + '`django.http.HttpRequest`, not `{}.{}`.' + .format(request.__class__.__module__, request.__class__.__name__) + ) + self._request = request self.parsers = parsers or () self.authenticators = authenticators or () diff --git a/tests/test_metadata.py b/tests/test_metadata.py index a9d2dc0c9..b9db36e81 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -9,12 +9,11 @@ from rest_framework import ( exceptions, metadata, serializers, status, versioning, views ) from rest_framework.renderers import BrowsableAPIRenderer -from rest_framework.request import Request from rest_framework.test import APIRequestFactory from .models import BasicModel -request = Request(APIRequestFactory().options('/')) +request = APIRequestFactory().options('/') class TestMetadata: diff --git a/tests/test_request.py b/tests/test_request.py index cbadb1467..c14233a6f 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -25,6 +25,18 @@ from rest_framework.views import APIView factory = APIRequestFactory() +class TestInitializer(TestCase): + def test_request_type(self): + request = Request(factory.get('/')) + + message = ( + 'The `request` argument must be an instance of ' + '`django.http.HttpRequest`, not `rest_framework.request.Request`.' + ) + with self.assertRaisesMessage(AssertionError, message): + Request(request) + + class PlainTextParser(BaseParser): media_type = 'text/plain' From c63e35cb09170e1166896ad31a1bb9a121aaa2f8 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Thu, 23 Nov 2017 02:58:04 -0500 Subject: [PATCH 195/217] Fix AttributeError hiding on request authenticators (#5600) * Update assertion style in user logout test * Apply middlewares to django request object * Fix test for request auth hiding AttributeErrors * Re-raise/wrap auth attribute errors * Fix test for py2k * Add docs for WrappedAttributeError --- docs/api-guide/authentication.md | 6 +++++ docs/api-guide/requests.md | 4 +++ rest_framework/request.py | 32 ++++++++++++++++++++--- tests/test_request.py | 44 +++++++++++++++++++------------- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index a7a24029b..63a789dfc 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -291,6 +291,12 @@ You *may* also override the `.authenticate_header(self, request)` method. If im If the `.authenticate_header()` method is not overridden, the authentication scheme will return `HTTP 403 Forbidden` responses when an unauthenticated request is denied access. +--- + +**Note:** When your custom authenticator is invoked by the request object's `.user` or `.auth` properties, you may see an `AttributeError` re-raised as a `WrappedAttributeError`. This is necessary to prevent the original exception from being suppressed by the outer property access. Python will not recognize that the `AttributeError` orginates from your custom authenticator and will instead assume that the request object does not have a `.user` or `.auth` property. These errors should be fixed or otherwise handled by your authenticator. + +--- + ## Example The following example will authenticate any incoming request as the user given by the username in a custom request header named 'X_USERNAME'. diff --git a/docs/api-guide/requests.md b/docs/api-guide/requests.md index 393b1ab9a..83a38d1c3 100644 --- a/docs/api-guide/requests.md +++ b/docs/api-guide/requests.md @@ -90,6 +90,10 @@ You won't typically need to access this property. --- +**Note:** You may see a `WrappedAttributeError` raised when calling the `.user` or `.auth` properties. These errors originate from an authenticator as a standard `AttributeError`, however it's necessary that they be re-raised as a different exception type in order to prevent them from being suppressed by the outer property access. Python will not recognize that the `AttributeError` orginates from the authenticator and will instaed assume that the request object does not have a `.user` or `.auth` property. The authenticator will need to be fixed. + +--- + # Browser enhancements REST framework supports a few browser enhancements such as browser-based `PUT`, `PATCH` and `DELETE` forms. diff --git a/rest_framework/request.py b/rest_framework/request.py index 5c9cb6136..7e4daf274 100644 --- a/rest_framework/request.py +++ b/rest_framework/request.py @@ -10,6 +10,9 @@ The wrapped request then offers a richer API, in particular : """ from __future__ import unicode_literals +import sys +from contextlib import contextmanager + from django.conf import settings from django.http import HttpRequest, QueryDict from django.http.multipartparser import parse_header @@ -59,6 +62,24 @@ class override_method(object): self.view.action = self.action +class WrappedAttributeError(Exception): + pass + + +@contextmanager +def wrap_attributeerrors(): + """ + Used to re-raise AttributeErrors caught during authentication, preventing + these errors from otherwise being handled by the attribute access protocol. + """ + try: + yield + except AttributeError: + info = sys.exc_info() + exc = WrappedAttributeError(str(info[1])) + six.reraise(type(exc), exc, info[2]) + + class Empty(object): """ Placeholder for unset attributes. @@ -197,7 +218,8 @@ class Request(object): by the authentication classes provided to the request. """ if not hasattr(self, '_user'): - self._authenticate() + with wrap_attributeerrors(): + self._authenticate() return self._user @user.setter @@ -220,7 +242,8 @@ class Request(object): request, such as an authentication token. """ if not hasattr(self, '_auth'): - self._authenticate() + with wrap_attributeerrors(): + self._authenticate() return self._auth @auth.setter @@ -239,7 +262,8 @@ class Request(object): to authenticate the request, or `None`. """ if not hasattr(self, '_authenticator'): - self._authenticate() + with wrap_attributeerrors(): + self._authenticate() return self._authenticator def _load_data_and_files(self): @@ -322,7 +346,7 @@ class Request(object): try: parsed = parser.parse(stream, media_type, self.parser_context) - except: + except Exception: # If we get an exception during parsing, fill in empty data and # re-raise. Ensures we don't simply repeat the error when # attempting to render the browsable renderer response, or when diff --git a/tests/test_request.py b/tests/test_request.py index c14233a6f..76589a440 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -6,8 +6,10 @@ from __future__ import unicode_literals import os.path import tempfile +import pytest from django.conf.urls import url from django.contrib.auth import authenticate, login, logout +from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.models import User from django.contrib.sessions.middleware import SessionMiddleware from django.core.files.uploadedfile import SimpleUploadedFile @@ -17,7 +19,7 @@ from django.utils import six from rest_framework import status from rest_framework.authentication import SessionAuthentication from rest_framework.parsers import BaseParser, FormParser, MultiPartParser -from rest_framework.request import Request +from rest_framework.request import Request, WrappedAttributeError from rest_framework.response import Response from rest_framework.test import APIClient, APIRequestFactory from rest_framework.views import APIView @@ -197,7 +199,8 @@ class TestUserSetter(TestCase): # available to login and logout functions self.wrapped_request = factory.get('/') self.request = Request(self.wrapped_request) - SessionMiddleware().process_request(self.request) + SessionMiddleware().process_request(self.wrapped_request) + AuthenticationMiddleware().process_request(self.wrapped_request) User.objects.create_user('ringo', 'starr@thebeatles.com', 'yellow') self.user = authenticate(username='ringo', password='yellow') @@ -212,9 +215,9 @@ class TestUserSetter(TestCase): def test_user_can_logout(self): self.request.user = self.user - self.assertFalse(self.request.user.is_anonymous) + assert not self.request.user.is_anonymous logout(self.request) - self.assertTrue(self.request.user.is_anonymous) + assert self.request.user.is_anonymous def test_logged_in_user_is_set_on_wrapped_request(self): login(self.request, self.user) @@ -227,22 +230,27 @@ class TestUserSetter(TestCase): """ class AuthRaisesAttributeError(object): def authenticate(self, request): - import rest_framework - rest_framework.MISSPELLED_NAME_THAT_DOESNT_EXIST + self.MISSPELLED_NAME_THAT_DOESNT_EXIST - self.request = Request(factory.get('/'), authenticators=(AuthRaisesAttributeError(),)) - SessionMiddleware().process_request(self.request) + request = Request(self.wrapped_request, authenticators=(AuthRaisesAttributeError(),)) - login(self.request, self.user) - try: - self.request.user - except AttributeError as error: - assert str(error) in ( - "'module' object has no attribute 'MISSPELLED_NAME_THAT_DOESNT_EXIST'", # Python < 3.5 - "module 'rest_framework' has no attribute 'MISSPELLED_NAME_THAT_DOESNT_EXIST'", # Python >= 3.5 - ) - else: - assert False, 'AttributeError not raised' + # The middleware processes the underlying Django request, sets anonymous user + assert self.wrapped_request.user.is_anonymous + + # The DRF request object does not have a user and should run authenticators + expected = r"no attribute 'MISSPELLED_NAME_THAT_DOESNT_EXIST'" + with pytest.raises(WrappedAttributeError, match=expected): + request.user + + # python 2 hasattr fails for *any* exception, not just AttributeError + if six.PY2: + return + + with pytest.raises(WrappedAttributeError, match=expected): + hasattr(request, 'user') + + with pytest.raises(WrappedAttributeError, match=expected): + login(request, self.user) class TestAuthSetter(TestCase): From eb61eb2b86798ef4c1b1630b86fbb11d00ab55ef Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 24 Nov 2017 22:38:07 -0500 Subject: [PATCH 196/217] Update testing requirements --- requirements/requirements-codestyle.txt | 6 +++--- requirements/requirements-optionals.txt | 2 +- requirements/requirements-testing.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements/requirements-codestyle.txt b/requirements/requirements-codestyle.txt index a64cfa29f..1a51179f8 100644 --- a/requirements/requirements-codestyle.txt +++ b/requirements/requirements-codestyle.txt @@ -1,7 +1,7 @@ # PEP8 code linting, which we run on all commits. -flake8==3.4.1 +flake8==3.5.0 flake8-tidy-imports==1.1.0 -pep8==1.7.0 +pycodestyle==2.3.1 # Sort and lint imports -isort==4.2.5 +isort==4.2.15 diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt index 67525bebc..f27178a3f 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -2,6 +2,6 @@ pytz==2017.2 markdown==2.6.4 django-guardian==1.4.9 -django-filter==1.0.4 +django-filter==1.1.0 coreapi==2.3.1 coreschema==0.0.4 diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt index 515cff78d..72ce56d26 100644 --- a/requirements/requirements-testing.txt +++ b/requirements/requirements-testing.txt @@ -1,4 +1,4 @@ # PyTest for running the tests. -pytest==3.2.2 +pytest==3.2.5 pytest-django==3.1.2 pytest-cov==2.5.1 From 7b58a2c124f6c7f0e2f50d97d47d7b2b07cbc8e4 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Sat, 25 Nov 2017 21:06:13 -0500 Subject: [PATCH 197/217] Fix bare except statements --- rest_framework/schemas/inspectors.py | 2 +- rest_framework/utils/encoders.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 80dc49268..47f5b9e13 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -260,7 +260,7 @@ class AutoSchema(ViewInspector): # Attempt to infer a field description if possible. try: model_field = model._meta.get_field(variable) - except: + except Exception: model_field = None if model_field is not None and model_field.verbose_name: diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 7518d4ffd..148a2c9c0 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -61,7 +61,7 @@ class JSONEncoder(json.JSONEncoder): elif hasattr(obj, '__getitem__'): try: return dict(obj) - except: + except Exception: pass elif hasattr(obj, '__iter__'): return tuple(item for item in obj) From 5c19652080e872b6dc13d6576e9a43ee821ae122 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Sat, 25 Nov 2017 21:10:30 -0500 Subject: [PATCH 198/217] Fix whitespace in imports --- rest_framework/templatetags/rest_framework.py | 1 + rest_framework/validators.py | 1 - tests/importable/test_installed.py | 1 + tests/test_description.py | 2 +- tests/test_one_to_one_with_inheritance.py | 1 - 5 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index bc38c0a34..a331339a6 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -10,6 +10,7 @@ from django.utils import six from django.utils.encoding import force_text, iri_to_uri from django.utils.html import escape, format_html, smart_urlquote from django.utils.safestring import SafeData, mark_safe + from rest_framework.compat import apply_markdown, pygments_highlight from rest_framework.renderers import HTMLFormRenderer from rest_framework.utils.urls import replace_query_param diff --git a/rest_framework/validators.py b/rest_framework/validators.py index 7f7740711..2ea3e5ac1 100644 --- a/rest_framework/validators.py +++ b/rest_framework/validators.py @@ -19,7 +19,6 @@ from rest_framework.utils.representation import smart_repr # Robust filter and exist implementations. Ensures that queryset.exists() for # an invalid value returns `False`, rather than raising an error. # Refs https://github.com/encode/django-rest-framework/issues/3381 - def qs_exists(queryset): try: return queryset.exists() diff --git a/tests/importable/test_installed.py b/tests/importable/test_installed.py index fff51fd8f..072d3b2e4 100644 --- a/tests/importable/test_installed.py +++ b/tests/importable/test_installed.py @@ -1,4 +1,5 @@ from django.conf import settings + from tests import importable diff --git a/tests/test_description.py b/tests/test_description.py index b3e8b0f8b..6ccbec882 100644 --- a/tests/test_description.py +++ b/tests/test_description.py @@ -33,9 +33,9 @@ indented }] ```""" + # If markdown is installed we also test it's working # (and that our wrapped forces '=' to h2 and '-' to h3) - MARKED_DOWN_HILITE = """
      [{
      "alpha" Date: Sat, 25 Nov 2017 21:19:55 -0500 Subject: [PATCH 199/217] Add _pytest to .isort.cfg --- .isort.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.isort.cfg b/.isort.cfg index 4d4a6a509..fd9c67a97 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -3,5 +3,5 @@ skip=.tox atomic=true multi_line_output=5 known_standard_library=types -known_third_party=pytest,django +known_third_party=pytest,_pytest,django known_first_party=rest_framework From 224d8cfb9da89454ea71821454680ee3e8569028 Mon Sep 17 00:00:00 2001 From: Akshar Raaj Date: Mon, 27 Nov 2017 13:38:18 +0530 Subject: [PATCH 200/217] Serializer._declared_fields enable modifying fields on a serializer instance without affecting every other serializer instance. --- 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 0952e190c..fa6a6f0bb 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -384,7 +384,7 @@ class Serializer(BaseSerializer): """ # Every new serializer is created with a clone of the field instances. # This allows users to dynamically modify the fields on a serializer - # instance without affecting every other serializer class. + # instance without affecting every other serializer instance. return copy.deepcopy(self._declared_fields) def get_validators(self): From abef84fb600ef714befde42243317ef767ef0ba8 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 27 Nov 2017 05:28:25 -0500 Subject: [PATCH 201/217] Fix packaging (#5624) * Packaging should use manifest * Add schema.js template to MANIFEST --- MANIFEST.in | 2 +- setup.py | 31 +++---------------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 15bfe4caa..48ec57edf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ include README.md include LICENSE.md recursive-include rest_framework/static *.js *.css *.png *.eot *.svg *.ttf *.woff -recursive-include rest_framework/templates *.html +recursive-include rest_framework/templates *.html schema.js global-exclude __pycache__ global-exclude *.py[co] diff --git a/setup.py b/setup.py index 385413052..736df7b12 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import shutil import sys from io import open -from setuptools import setup +from setuptools import setup, find_packages try: from pypandoc import convert @@ -28,31 +28,6 @@ def get_version(package): return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1) -def get_packages(package): - """ - Return root package and all sub-packages. - """ - return [dirpath - for dirpath, dirnames, filenames in os.walk(package) - if os.path.exists(os.path.join(dirpath, '__init__.py'))] - - -def get_package_data(package): - """ - Return all files under the root package, that are not in a - package themselves. - """ - walk = [(dirpath.replace(package + os.sep, '', 1), filenames) - for dirpath, dirnames, filenames in os.walk(package) - if not os.path.exists(os.path.join(dirpath, '__init__.py'))] - - filepaths = [] - for base, filenames in walk: - filepaths.extend([os.path.join(base, filename) - for filename in filenames]) - return {package: filepaths} - - version = get_version('rest_framework') @@ -84,8 +59,8 @@ setup( long_description=read_md('README.md'), author='Tom Christie', author_email='tom@tomchristie.com', # SEE NOTE BELOW (*) - packages=get_packages('rest_framework'), - package_data=get_package_data('rest_framework'), + packages=find_packages(exclude=['tests*']), + include_package_data=True, install_requires=[], zip_safe=False, classifiers=[ From fc6b192b708c67b3c2ff2da5e249502e33afdb60 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 27 Nov 2017 05:32:17 -0500 Subject: [PATCH 202/217] Fix readme, add to CI (#5625) * Add readme build to CI * Fix pandoc import in setup.py * Replace sponsor HTML with markdown This loses the image centering, but can be converted to RST. * Fix README RST conversion - Links do not render correctly inside italics - Add hr between image caption and section, fixes markup on older versions of pandoc. --- .travis.yml | 4 ++++ README.md | 30 +++++++++++++++++-------- requirements/requirements-packaging.txt | 3 +++ setup.py | 4 ++-- tox.ini | 9 ++++++-- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c9ad7a4e..c5a15140d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,10 @@ matrix: - { python: "3.6", env: DJANGO=2.0 } - { python: "2.7", env: TOXENV=lint } - { python: "2.7", env: TOXENV=docs } + - python: "2.7" + env: TOXENV=readme + addons: + apt_packages: pandoc exclude: - { python: "2.7", env: DJANGO=master } - { python: "2.7", env: DJANGO=2.0 } diff --git a/README.md b/README.md index ceac9e57c..c19105bc7 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,18 @@ Full documentation for the project is available at [http://www.django-rest-frame REST framework is a *collaboratively funded project*. If you use REST framework commercially we strongly encourage you to invest in its -continued development by **[signing up for a paid plan][funding]**. +continued development by [signing up for a paid plan][funding]. The initial aim is to provide a single full-time position on REST framework. *Every single sign-up makes a significant impact towards making that possible.* -

      - - - - - -

      +[![][rover-img]][rover-url] +[![][sentry-img]][sentry-url] +[![][stream-img]][stream-url] +[![][machinalis-img]][machinalis-url] +[![][rollbar-img]][rollbar-url] -*Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Rover](http://jobs.rover.com/), [Sentry](https://getsentry.com/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [Machinalis](https://hello.machinalis.co.uk/), and [Rollbar](https://rollbar.com/).* +Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Rover][rover-url], [Sentry][sentry-url], [Stream][stream-url], [Machinalis][machinalis-url], and [Rollbar][rollbar-url]. --- @@ -50,6 +48,8 @@ There is a live example API for testing purposes, [available here][sandbox]. ![Screenshot][image] +---- + # Requirements * Python (2.7, 3.4, 3.5, 3.6) @@ -188,6 +188,18 @@ Send a description of the issue via email to [rest-framework-security@googlegrou [funding]: https://fund.django-rest-framework.org/topics/funding/ [sponsors]: https://fund.django-rest-framework.org/topics/funding/#our-sponsors +[rover-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/rover-readme.png +[sentry-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/sentry-readme.png +[stream-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/stream-readme.png +[machinalis-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/machinalis-readme.png +[rollbar-img]: https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/rollbar-readme.png + +[rover-url]: http://jobs.rover.com/ +[sentry-url]: https://getsentry.com/welcome/ +[stream-url]: https://getstream.io/try-the-api/?utm_source=drf&utm_medium=banner&utm_campaign=drf +[machinalis-url]: https://hello.machinalis.co.uk/ +[rollbar-url]: https://rollbar.com/ + [oauth1-section]: http://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth [oauth2-section]: http://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit [serializer-section]: http://www.django-rest-framework.org/api-guide/serializers/#serializers diff --git a/requirements/requirements-packaging.txt b/requirements/requirements-packaging.txt index f12d4af0e..76b15f832 100644 --- a/requirements/requirements-packaging.txt +++ b/requirements/requirements-packaging.txt @@ -9,3 +9,6 @@ transifex-client==0.11 # Pandoc to have a nice pypi page pypandoc + +# readme_renderer to check readme syntax +readme_renderer diff --git a/setup.py b/setup.py index 736df7b12..54acad01b 100755 --- a/setup.py +++ b/setup.py @@ -9,10 +9,10 @@ from io import open from setuptools import setup, find_packages try: - from pypandoc import convert + from pypandoc import convert_file def read_md(f): - return convert(f, 'rst') + return convert_file(f, 'rst') except ImportError: print("warning: pypandoc module not found, could not convert Markdown to RST") diff --git a/tox.ini b/tox.ini index e2c7c2feb..eea6bbf37 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,8 @@ envlist = {py27,py34,py35}-django110, {py27,py34,py35,py36}-django111, {py34,py35,py36}-django20, - {py35,py36}-djangomaster - lint,docs + {py35,py36}-djangomaster, + lint,docs,readme, [travis:env] DJANGO = @@ -42,3 +42,8 @@ commands = mkdocs build deps = -rrequirements/requirements-testing.txt -rrequirements/requirements-documentation.txt + +[testenv:readme] +commands = ./setup.py check -rs +deps = + -rrequirements/requirements-packaging.txt From 743fc247eba50e96ffda36825f49b0d529d8c29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Mon, 27 Nov 2017 05:34:17 -0500 Subject: [PATCH 203/217] Update tutorial (#5622) * Use createsuperuser email and username flags * Only remove db.sqlite3 * Remove global permission class This interferes with Core API schema endpoint * Add default pagination class * Specify changes made in snippets/urls.py * Auth urls were already set in tutorial/urls.py * Specify changes made in snippets/urls.py * Use the suggested admin username from quickstart * Move global pagination setting away from quickstart section --- docs/tutorial/2-requests-and-responses.md | 2 +- docs/tutorial/3-class-based-views.md | 2 +- docs/tutorial/4-authentication-and-permissions.md | 6 +++--- docs/tutorial/5-relationships-and-hyperlinked-apis.md | 11 +++-------- docs/tutorial/6-viewsets-and-routers.md | 10 ++++------ docs/tutorial/quickstart.md | 11 ++--------- 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index e55ffa709..7fb1b2f2e 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -106,7 +106,7 @@ and def snippet_detail(request, pk, format=None): -Now update the `urls.py` file slightly, to append a set of `format_suffix_patterns` in addition to the existing URLs. +Now update the `snippets/urls.py` file slightly, to append a set of `format_suffix_patterns` in addition to the existing URLs. from django.conf.urls import url from rest_framework.urlpatterns import format_suffix_patterns diff --git a/docs/tutorial/3-class-based-views.md b/docs/tutorial/3-class-based-views.md index 5a8cdd46a..5c3b97929 100644 --- a/docs/tutorial/3-class-based-views.md +++ b/docs/tutorial/3-class-based-views.md @@ -62,7 +62,7 @@ So far, so good. It looks pretty similar to the previous case, but we've got be That's looking good. Again, it's still pretty similar to the function based view right now. -We'll also need to refactor our `urls.py` slightly now that we're using class-based views. +We'll also need to refactor our `snippets/urls.py` slightly now that we're using class-based views. from django.conf.urls import url from rest_framework.urlpatterns import format_suffix_patterns diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md index 72cf64e37..6e5b077ce 100644 --- a/docs/tutorial/4-authentication-and-permissions.md +++ b/docs/tutorial/4-authentication-and-permissions.md @@ -43,7 +43,7 @@ And now we can add a `.save()` method to our model class: When that's all done we'll need to update our database tables. Normally we'd create a database migration in order to do that, but for the purposes of this tutorial, let's just delete the database and start again. - rm -f tmp.db db.sqlite3 + rm -f db.sqlite3 rm -r snippets/migrations python manage.py makemigrations snippets python manage.py migrate @@ -205,11 +205,11 @@ If we try to create a snippet without authenticating, we'll get an error: We can make a successful request by including the username and password of one of the users we created earlier. - http -a tom:password123 POST http://127.0.0.1:8000/snippets/ code="print 789" + http -a admin:password123 POST http://127.0.0.1:8000/snippets/ code="print 789" { "id": 1, - "owner": "tom", + "owner": "admin", "title": "foo", "code": "print 789", "linenos": false, diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md index 9fd61b414..1e4da788e 100644 --- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md +++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md @@ -130,23 +130,18 @@ After adding all those names into our URLconf, our final `snippets/urls.py` file name='user-detail') ]) - # Login and logout views for the browsable API - urlpatterns += [ - url(r'^api-auth/', include('rest_framework.urls', - namespace='rest_framework')), - ] - ## Adding pagination The list views for users and code snippets could end up returning quite a lot of instances, so really we'd like to make sure we paginate the results, and allow the API client to step through each of the individual pages. -We can change the default list style to use pagination, by modifying our `tutorial/settings.py` file slightly. Add the following setting: +We can change the default list style to use pagination, by modifying our `tutorial/settings.py` file slightly. Add the following setting: REST_FRAMEWORK = { + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': 10 } -Note that settings in REST framework are all namespaced into a single dictionary setting, named 'REST_FRAMEWORK', which helps keep them well separated from your other project settings. +Note that settings in REST framework are all namespaced into a single dictionary setting, named `REST_FRAMEWORK`, which helps keep them well separated from your other project settings. We could also customize the pagination style if we needed too, but in this case we'll just stick with the default. diff --git a/docs/tutorial/6-viewsets-and-routers.md b/docs/tutorial/6-viewsets-and-routers.md index 252021e39..7d87c0212 100644 --- a/docs/tutorial/6-viewsets-and-routers.md +++ b/docs/tutorial/6-viewsets-and-routers.md @@ -61,7 +61,7 @@ The URLs for custom actions by default depend on the method name itself. If you The handler methods only get bound to the actions when we define the URLConf. To see what's going on under the hood let's first explicitly create a set of views from our ViewSets. -In the `urls.py` file we bind our `ViewSet` classes into a set of concrete views. +In the `snippets/urls.py` file we bind our `ViewSet` classes into a set of concrete views. from snippets.views import SnippetViewSet, UserViewSet, api_root from rest_framework import renderers @@ -103,11 +103,11 @@ Now that we've bound our resources into concrete views, we can register the view Because we're using `ViewSet` classes rather than `View` classes, we actually don't need to design the URL conf ourselves. The conventions for wiring up resources into views and urls can be handled automatically, using a `Router` class. All we need to do is register the appropriate view sets with a router, and let it do the rest. -Here's our re-wired `urls.py` file. +Here's our re-wired `snippets/urls.py` file. from django.conf.urls import url, include - from snippets import views from rest_framework.routers import DefaultRouter + from snippets import views # Create a router and register our viewsets with it. router = DefaultRouter() @@ -115,10 +115,8 @@ Here's our re-wired `urls.py` file. router.register(r'users', views.UserViewSet) # The API URLs are now determined automatically by the router. - # Additionally, we include the login URLs for the browsable API. urlpatterns = [ - url(r'^', include(router.urls)), - url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) + url(r'^', include(router.urls)) ] Registering the viewsets with the router is similar to providing a urlpattern. We include two arguments - the URL prefix for the views, and the viewset itself. diff --git a/docs/tutorial/quickstart.md b/docs/tutorial/quickstart.md index 31361413e..ab789518d 100644 --- a/docs/tutorial/quickstart.md +++ b/docs/tutorial/quickstart.md @@ -54,7 +54,7 @@ Now sync your database for the first time: We'll also create an initial user named `admin` with a password of `password123`. We'll authenticate as that user later in our example. - python manage.py createsuperuser + python manage.py createsuperuser --email admin@example.com --username admin Once you've set up a database and initial user created and ready to go, open up the app's directory and we'll get coding... @@ -134,20 +134,13 @@ Finally, we're including default login and logout views for use with the browsab ## Settings -We'd also like to set a few global settings. We'd like to turn on pagination, and we want our API to only be accessible to admin users. The settings module will be in `tutorial/settings.py` +Add `'rest_framework'` to `INSTALLED_APPS`. The settings module will be in `tutorial/settings.py` INSTALLED_APPS = ( ... 'rest_framework', ) - REST_FRAMEWORK = { - 'DEFAULT_PERMISSION_CLASSES': [ - 'rest_framework.permissions.IsAdminUser', - ], - 'PAGE_SIZE': 10 - } - Okay, we're done. --- From 97f7a82b372d22e588c8771398971ecdd517cdb7 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Tue, 28 Nov 2017 16:46:34 +0100 Subject: [PATCH 204/217] Correct typos Closes #5634 --- docs/topics/release-notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 9ac3ab100..44d8c7a12 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -43,14 +43,14 @@ You can determine your currently installed version using `pip freeze`: ### 3.7.3 -**Date**: [6th Novemember 2017][3.7.3-milestone] +**Date**: [6th November 2017][3.7.3-milestone] * Fix `AppRegistryNotReady` error from contrib.auth view imports [#5567][gh5567] ### 3.7.2 -**Date**: [6th Novemember 2017][3.7.2-milestone] +**Date**: [6th November 2017][3.7.2-milestone] * Fixed Django 2.1 compatibility due to removal of django.contrib.auth.login()/logout() views. [#5510][gh5510] * Add missing import for TextLexer. [#5512][gh5512] From 905a5579dfaa717ad4210ddd285267bb9bbb9a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Oliveira?= Date: Fri, 1 Dec 2017 06:54:25 -0200 Subject: [PATCH 205/217] Non-required fields with 'allow_null=True' should not imply a default value (#5639) Ref #5518. --- rest_framework/fields.py | 4 ++-- tests/test_serializer.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 55c2fe48e..a710df7b4 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -442,10 +442,10 @@ class Field(object): except (KeyError, AttributeError) as exc: if self.default is not empty: return self.get_default() - if self.allow_null: - return None if not self.required: raise SkipField() + if self.allow_null: + return None msg = ( 'Got {exc_type} when attempting to get a value for field ' '`{field}` on serializer `{serializer}`.\nThe serializer ' diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 23c6ec2c1..0c30deb91 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -372,6 +372,14 @@ class TestNotRequiredOutput: serializer.save() assert serializer.data == {'included': 'abc'} + def test_not_required_output_for_allow_null_field(self): + class ExampleSerializer(serializers.Serializer): + omitted = serializers.CharField(required=False, allow_null=True) + included = serializers.CharField() + + serializer = ExampleSerializer({'included': 'abc'}) + assert 'omitted' not in serializer.data + class TestDefaultOutput: def setup(self): From 5f42cb70270d698df57df679726964e7fad11f45 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Fri, 1 Dec 2017 04:07:33 -0500 Subject: [PATCH 206/217] Add allow_null serialization output note (#5641) --- docs/api-guide/fields.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index d209a945b..8d61f2cbc 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -45,6 +45,8 @@ Defaults to `True`. Normally an error will be raised if `None` is passed to a serializer field. Set this keyword argument to `True` if `None` should be considered a valid value. +Note that setting this argument to `True` will imply a default value of `null` for serialization output, but does imply a default for input deserialization. + Defaults to `False` ### `default` From 101d3d24f701e52e1b4a0e1c5a0124482ff26f4c Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 3 Dec 2017 10:33:26 -0800 Subject: [PATCH 207/217] Update to use the Django 2.0 release in tox.ini Was previously using a release candidate as the minimum version. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index eea6bbf37..e2d7aa448 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ setenv = deps = django110: Django>=1.10,<1.11 django111: Django>=1.11,<2.0 - django20: Django>=2.0rc1,<2.1 + django20: Django>=2.0,<2.1 djangomaster: https://github.com/django/django/archive/master.tar.gz -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt From daba5e9ba5cea03d56e76baa4bf05d67b7ac6cea Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 4 Dec 2017 02:39:55 -0500 Subject: [PATCH 208/217] Fix Serializer.data when provided invalid 'data' (#5646) * Test serializer/API renderer for invalid datatype * Fix Serializer.data with invalid input datatype --- rest_framework/serializers.py | 4 +++ tests/browsable_api/test_form_rendering.py | 30 ++++++++++++++++++++++ tests/test_serializer.py | 9 +++++++ 3 files changed, 43 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index fa6a6f0bb..e2ea0d744 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -398,6 +398,10 @@ class Serializer(BaseSerializer): def get_initial(self): if hasattr(self, 'initial_data'): + # initial_data may not be a valid type + if not isinstance(self.initial_data, Mapping): + return OrderedDict() + return OrderedDict([ (field_name, field.get_value(self.initial_data)) for field_name, field in self.fields.items() diff --git a/tests/browsable_api/test_form_rendering.py b/tests/browsable_api/test_form_rendering.py index 47186c783..d8378a2ca 100644 --- a/tests/browsable_api/test_form_rendering.py +++ b/tests/browsable_api/test_form_rendering.py @@ -14,6 +14,10 @@ class BasicSerializer(serializers.ModelSerializer): fields = '__all__' +class StandardPostView(generics.CreateAPIView): + serializer_class = BasicSerializer + + class ManyPostView(generics.GenericAPIView): queryset = BasicModel.objects.all() serializer_class = BasicSerializer @@ -24,6 +28,32 @@ class ManyPostView(generics.GenericAPIView): return Response(serializer.data, status.HTTP_200_OK) +class TestPostingListData(TestCase): + """ + POSTing a list of data to a regular view should not cause the browsable + API to fail during rendering. + + Regression test for https://github.com/encode/django-rest-framework/issues/5637 + """ + + def test_json_response(self): + # sanity check for non-browsable API responses + view = StandardPostView.as_view() + request = factory.post('/', [{}], format='json') + response = view(request).render() + + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.assertTrue('non_field_errors' in response.data) + + def test_browsable_api(self): + view = StandardPostView.as_view() + request = factory.post('/?format=api', [{}], format='json') + response = view(request).render() + + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.assertTrue('non_field_errors' in response.data) + + class TestManyPostView(TestCase): def setUp(self): """ diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 0c30deb91..da1394515 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -77,14 +77,23 @@ class TestSerializer: serializer = self.Serializer(data={'char': 'abc', 'integer': 123}) assert serializer.is_valid() assert serializer.validated_data == {'char': 'abc', 'integer': 123} + assert serializer.data == {'char': 'abc', 'integer': 123} assert serializer.errors == {} def test_invalid_serializer(self): serializer = self.Serializer(data={'char': 'abc'}) assert not serializer.is_valid() assert serializer.validated_data == {} + assert serializer.data == {'char': 'abc'} assert serializer.errors == {'integer': ['This field is required.']} + def test_invalid_datatype(self): + serializer = self.Serializer(data=[{'char': 'abc'}]) + assert not serializer.is_valid() + assert serializer.validated_data == {} + assert serializer.data == {} + assert serializer.errors == {'non_field_errors': ['Invalid data. Expected a dictionary, but got list.']} + def test_partial_validation(self): serializer = self.Serializer(data={'char': 'abc'}, partial=True) assert serializer.is_valid() From a0cdba627767ec489fbc683483a8904bdfe606a9 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 4 Dec 2017 09:07:43 +0100 Subject: [PATCH 209/217] Extract method for `manual_fields` processing (#5633) * Extract method for `manual_fields` processing Allows reuse of logic to replace Field instances in a field list by `Field.name`. Adds a utility function for the logic plus a wrapper method on `AutoSchema`. Closes #5632 * Manual fields suggestions (#2) * Use OrderedDict in inspectors * Move empty check to 'update_fields()' * Make 'update_fields()' an AutoSchema staticmethod * Add 'AutoSchema.get_manual_fields()' * Conform '.get_manual_fields()' to other methods * Add test for update_fields * Make sure `manual_fields` is a list. (As documented to be) * Add docs for new AutoSchema methods. * `get_manual_fields` * `update_fields` * Add release notes for PR. --- docs/api-guide/schemas.md | 25 +++++++++++++++++ docs/topics/release-notes.md | 19 +++++++++++++ rest_framework/schemas/inspectors.py | 35 +++++++++++++++++++----- tests/test_schemas.py | 40 ++++++++++++++++++++++++++-- 4 files changed, 111 insertions(+), 8 deletions(-) diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 22894a978..2b83e0671 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -603,6 +603,31 @@ Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fiel Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fields()` method of any filter classes used by the view. +### get_manual_fields(self, path, method) + +Return a list of `coreapi.Field()` instances to be added to or replace generated fields. Defaults to (optional) `manual_fields` passed to `AutoSchema` constructor. + +May be overridden to customise manual fields by `path` or `method`. For example, a per-method adjustment may look like this: + +```python +def get_manual_fields(self, path, method): + """Example adding per-method fields.""" + + extra_fields = [] + if method=='GET': + extra_fields = # ... list of extra fields for GET ... + if method=='POST': + extra_fields = # ... list of extra fields for POST ... + + manual_fields = super().get_manual_fields() + return manual_fields + extra_fields +``` + +### update_fields(fields, update_with) + +Utility `staticmethod`. Encapsulates logic to add or replace fields from a list +by `Field.name`. May be overridden to adjust replacement criteria. + ## ManualSchema diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 44d8c7a12..2f2cdf1a1 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -40,6 +40,25 @@ You can determine your currently installed version using `pip freeze`: ## 3.7.x series +### 3.7.4 + +**Date**: UNRELEASED + +* Extract method for `manual_fields` processing [#5633][gh5633] + + Allows for easier customisation of `manual_fields` processing, for example + to provide per-method manual fields. `AutoSchema` adds `get_manual_fields`, + as the intended override point, and a utility method `update_fields`, to + handle by-name field replacement from a list, which, in general, you are not + expected to override. + + Note: `AutoSchema.__init__` now ensures `manual_fields` is a list. + Previously may have been stored internally as `None`. + + +[gh5633]: https://github.com/encode/django-rest-framework/issues/5633 + + ### 3.7.3 diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 47f5b9e13..008d7c091 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -172,7 +172,8 @@ class AutoSchema(ViewInspector): * `manual_fields`: list of `coreapi.Field` instances that will be added to auto-generated fields, overwriting on `Field.name` """ - + if manual_fields is None: + manual_fields = [] self._manual_fields = manual_fields def get_link(self, path, method, base_url): @@ -181,11 +182,8 @@ class AutoSchema(ViewInspector): fields += self.get_pagination_fields(path, method) fields += self.get_filter_fields(path, method) - if self._manual_fields is not None: - by_name = {f.name: f for f in fields} - for f in self._manual_fields: - by_name[f.name] = f - fields = list(by_name.values()) + manual_fields = self.get_manual_fields(path, method) + fields = self.update_fields(fields, manual_fields) if fields and any([field.location in ('form', 'body') for field in fields]): encoding = self.get_encoding(path, method) @@ -379,6 +377,31 @@ class AutoSchema(ViewInspector): fields += filter_backend().get_schema_fields(self.view) return fields + def get_manual_fields(self, path, method): + return self._manual_fields + + @staticmethod + def update_fields(fields, update_with): + """ + Update list of coreapi.Field instances, overwriting on `Field.name`. + + Utility function to handle replacing coreapi.Field fields + from a list by name. Used to handle `manual_fields`. + + Parameters: + + * `fields`: list of `coreapi.Field` instances to update + * `update_with: list of `coreapi.Field` instances to add or replace. + """ + if not update_with: + return fields + + by_name = OrderedDict((f.name, f) for f in fields) + for f in update_with: + by_name[f.name] = f + fields = list(by_name.values()) + return fields + def get_encoding(self, path, method): """ Return the 'encoding' parameter to use for a given endpoint. diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 56692d4f5..ba561a959 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -516,7 +516,7 @@ class Test4605Regression(TestCase): assert prefix == '/' -class TestDescriptor(TestCase): +class TestAutoSchema(TestCase): def test_apiview_schema_descriptor(self): view = APIView() @@ -528,7 +528,43 @@ class TestDescriptor(TestCase): with pytest.raises(AssertionError): descriptor.get_link(None, None, None) # ???: Do the dummy arguments require a tighter assert? - def test_manual_fields(self): + def test_update_fields(self): + """ + That updating fields by-name helper is correct + + Recall: `update_fields(fields, update_with)` + """ + schema = AutoSchema() + fields = [] + + # Adds a field... + fields = schema.update_fields(fields, [ + coreapi.Field( + "my_field", + required=True, + location="path", + schema=coreschema.String() + ), + ]) + + assert len(fields) == 1 + assert fields[0].name == "my_field" + + # Replaces a field... + fields = schema.update_fields(fields, [ + coreapi.Field( + "my_field", + required=False, + location="path", + schema=coreschema.String() + ), + ]) + + assert len(fields) == 1 + assert fields[0].required is False + + def test_get_manual_fields(self): + """That get_manual_fields is applied during get_link""" class CustomView(APIView): schema = AutoSchema(manual_fields=[ From c7df69ab7703c7ed345a445fe1b16ac52c40f026 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 4 Dec 2017 10:52:59 +0100 Subject: [PATCH 210/217] Note AutoSchema limitations on bare APIView (#5649) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AutoSchema uses GenericAPIView hooks to introspect. If these are not present it’s results will be limited. Note this. Closes #5121 --- docs/api-guide/schemas.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 2b83e0671..9234212ea 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -167,6 +167,18 @@ appropriate Core API `Link` object for the view, request method and path: (In compiling the schema, `SchemaGenerator` calls `view.schema.get_link()` for each view, allowed method and path.) +--- + +**Note**: For basic `APIView` subclasses, default introspection is essentially +limited to the URL kwarg path parameters. For `GenericAPIView` +subclasses, which includes all the provided class based views, `AutoSchema` will +attempt to introspect serialiser, pagination and filter fields, as well as +provide richer path field descriptions. (The key hooks here are the relevant +`GenericAPIView` attributes and methods: `get_serializer`, `pagination_class`, +`filter_backends` and so on.) + +--- + To customise the `Link` generation you may: * Instantiate `AutoSchema` on your view with the `manual_fields` kwarg: From 7855d3bd8b607ed8aed1a2266b35e3e3ef265288 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Mon, 4 Dec 2017 05:55:49 -0500 Subject: [PATCH 211/217] Add '.basename' and '.reverse_action()' to ViewSet (#5648) * Router sets 'basename' on ViewSet * Add 'ViewSet.reverse_action()' method * Test router setting initkwargs --- docs/api-guide/viewsets.md | 15 +++++++ rest_framework/routers.py | 7 +++- rest_framework/viewsets.py | 16 ++++++- tests/test_routers.py | 16 +++++++ tests/test_viewsets.py | 86 +++++++++++++++++++++++++++++++++++++- 5 files changed, 137 insertions(+), 3 deletions(-) diff --git a/docs/api-guide/viewsets.md b/docs/api-guide/viewsets.md index a8fc6afef..04ce7357d 100644 --- a/docs/api-guide/viewsets.md +++ b/docs/api-guide/viewsets.md @@ -159,6 +159,21 @@ These decorators will route `GET` requests by default, but may also accept other The two new actions will then be available at the urls `^users/{pk}/set_password/$` and `^users/{pk}/unset_password/$` +## Reversing action URLs + +If you need to get the URL of an action, use the `.reverse_action()` method. This is a convenience wrapper for `reverse()`, automatically passing the view's `request` object and prepending the `url_name` with the `.basename` attribute. + +Note that the `basename` is provided by the router during `ViewSet` registration. If you are not using a router, then you must provide the `basename` argument to the `.as_view()` method. + +Using the example from the previous section: + +```python +>>> view.reverse_action('set-password', args=['1']) +'http://localhost:8000/api/users/1/set_password' +``` + +The `url_name` argument should match the same argument to the `@list_route` and `@detail_route` decorators. Additionally, this can be used to reverse the default `list` and `detail` routes. + --- # API Reference diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 2010a1138..f4d2fab38 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -278,7 +278,12 @@ class SimpleRouter(BaseRouter): if not prefix and regex[:2] == '^/': regex = '^' + regex[2:] - view = viewset.as_view(mapping, **route.initkwargs) + initkwargs = route.initkwargs.copy() + initkwargs.update({ + 'basename': basename, + }) + + view = viewset.as_view(mapping, **initkwargs) name = route.name.format(basename=basename) ret.append(url(regex, view, name=name)) diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index 7f3c550a9..4ee7cdaf8 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -24,6 +24,7 @@ from django.utils.decorators import classonlymethod from django.views.decorators.csrf import csrf_exempt from rest_framework import generics, mixins, views +from rest_framework.reverse import reverse class ViewSetMixin(object): @@ -46,10 +47,14 @@ class ViewSetMixin(object): instantiated view, we need to totally reimplement `.as_view`, and slightly modify the view function that is created and returned. """ - # The suffix initkwarg is reserved for identifying the viewset type + # The suffix initkwarg is reserved for displaying the viewset type. # eg. 'List' or 'Instance'. cls.suffix = None + # Setting a basename allows a view to reverse its action urls. This + # value is provided by the router through the initkwargs. + cls.basename = None + # actions must not be empty if not actions: raise TypeError("The `actions` argument must be provided when " @@ -121,6 +126,15 @@ class ViewSetMixin(object): self.action = self.action_map.get(method) return request + def reverse_action(self, url_name, *args, **kwargs): + """ + Reverse the action for the given `url_name`. + """ + url_name = '%s-%s' % (self.basename, url_name) + kwargs.setdefault('request', self.request) + + return reverse(url_name, *args, **kwargs) + class ViewSet(ViewSetMixin, views.APIView): """ diff --git a/tests/test_routers.py b/tests/test_routers.py index 07a57fe55..5a1cfe8f4 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -7,6 +7,7 @@ from django.conf.urls import include, url from django.core.exceptions import ImproperlyConfigured from django.db import models from django.test import TestCase, override_settings +from django.urls import resolve from rest_framework import permissions, serializers, viewsets from rest_framework.compat import get_regex_pattern @@ -435,3 +436,18 @@ class TestRegexUrlPath(TestCase): response = self.client.get('/regex/{}/detail/{}/'.format(pk, kwarg)) assert response.status_code == 200 assert json.loads(response.content.decode('utf-8')) == {'pk': pk, 'kwarg': kwarg} + + +@override_settings(ROOT_URLCONF='tests.test_routers') +class TestViewInitkwargs(TestCase): + def test_suffix(self): + match = resolve('/example/notes/') + initkwargs = match.func.initkwargs + + assert initkwargs['suffix'] == 'List' + + def test_basename(self): + match = resolve('/example/notes/') + initkwargs = match.func.initkwargs + + assert initkwargs['basename'] == 'routertestmodel' diff --git a/tests/test_viewsets.py b/tests/test_viewsets.py index 846a36807..beff42cb8 100644 --- a/tests/test_viewsets.py +++ b/tests/test_viewsets.py @@ -1,7 +1,11 @@ -from django.test import TestCase +from django.conf.urls import include, url +from django.db import models +from django.test import TestCase, override_settings from rest_framework import status +from rest_framework.decorators import detail_route, list_route from rest_framework.response import Response +from rest_framework.routers import SimpleRouter from rest_framework.test import APIRequestFactory from rest_framework.viewsets import GenericViewSet @@ -22,6 +26,46 @@ class InstanceViewSet(GenericViewSet): return Response({'view': self}) +class Action(models.Model): + pass + + +class ActionViewSet(GenericViewSet): + queryset = Action.objects.all() + + def list(self, request, *args, **kwargs): + pass + + def retrieve(self, request, *args, **kwargs): + pass + + @list_route() + def list_action(self, request, *args, **kwargs): + pass + + @list_route(url_name='list-custom') + def custom_list_action(self, request, *args, **kwargs): + pass + + @detail_route() + def detail_action(self, request, *args, **kwargs): + pass + + @detail_route(url_name='detail-custom') + def custom_detail_action(self, request, *args, **kwargs): + pass + + +router = SimpleRouter() +router.register(r'actions', ActionViewSet) +router.register(r'actions-alt', ActionViewSet, base_name='actions-alt') + + +urlpatterns = [ + url(r'^api/', include(router.urls)), +] + + class InitializeViewSetsTestCase(TestCase): def test_initialize_view_set_with_actions(self): request = factory.get('/', '', content_type='application/json') @@ -65,3 +109,43 @@ class InitializeViewSetsTestCase(TestCase): for attribute in ('args', 'kwargs', 'request', 'action_map'): self.assertNotIn(attribute, dir(bare_view)) self.assertIn(attribute, dir(view)) + + +@override_settings(ROOT_URLCONF='tests.test_viewsets') +class ReverseActionTests(TestCase): + def test_default_basename(self): + view = ActionViewSet() + view.basename = router.get_default_base_name(ActionViewSet) + view.request = None + + assert view.reverse_action('list') == '/api/actions/' + assert view.reverse_action('list-action') == '/api/actions/list_action/' + assert view.reverse_action('list-custom') == '/api/actions/custom_list_action/' + + assert view.reverse_action('detail', args=['1']) == '/api/actions/1/' + assert view.reverse_action('detail-action', args=['1']) == '/api/actions/1/detail_action/' + assert view.reverse_action('detail-custom', args=['1']) == '/api/actions/1/custom_detail_action/' + + def test_custom_basename(self): + view = ActionViewSet() + view.basename = 'actions-alt' + view.request = None + + assert view.reverse_action('list') == '/api/actions-alt/' + assert view.reverse_action('list-action') == '/api/actions-alt/list_action/' + assert view.reverse_action('list-custom') == '/api/actions-alt/custom_list_action/' + + assert view.reverse_action('detail', args=['1']) == '/api/actions-alt/1/' + assert view.reverse_action('detail-action', args=['1']) == '/api/actions-alt/1/detail_action/' + assert view.reverse_action('detail-custom', args=['1']) == '/api/actions-alt/1/custom_detail_action/' + + def test_request_passing(self): + view = ActionViewSet() + view.basename = router.get_default_base_name(ActionViewSet) + view.request = factory.get('/') + + # Passing the view's request object should result in an absolute URL. + assert view.reverse_action('list') == 'http://testserver/api/actions/' + + # Users should be able to explicitly not pass the view's request. + assert view.reverse_action('list', request=None) == '/api/actions/' From 01587b9eb17bf68c716e84e616202d6e4ccbaecf Mon Sep 17 00:00:00 2001 From: Hang Park Date: Mon, 4 Dec 2017 21:00:03 +0900 Subject: [PATCH 212/217] Typos in serializers documentation (#5652) Fixes #5651. Change `update()` to `.update()` in serializers documentation to get a consistency with `.create()`. --- docs/api-guide/serializers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index ee6e41607..89196949d 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -73,7 +73,7 @@ Deserialization is similar. First we parse a stream into Python native datatypes ## Saving instances -If we want to be able to return complete object instances based on the validated data we need to implement one or both of the `.create()` and `update()` methods. For example: +If we want to be able to return complete object instances based on the validated data we need to implement one or both of the `.create()` and `.update()` methods. For example: class CommentSerializer(serializers.Serializer): email = serializers.EmailField() @@ -325,7 +325,7 @@ For updates you'll want to think carefully about how to handle updates to relati * Ignore the data and leave the instance as it is. * Raise a validation error. -Here's an example for an `update()` method on our previous `UserSerializer` class. +Here's an example for an `.update()` method on our previous `UserSerializer` class. def update(self, instance, validated_data): profile_data = validated_data.pop('profile') From 1692feb535472cb78c49328613a14aef48f77787 Mon Sep 17 00:00:00 2001 From: Anna Ossowski Date: Wed, 6 Dec 2017 03:10:41 +0100 Subject: [PATCH 213/217] Updated monthly report link --- docs/topics/funding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/funding.md b/docs/topics/funding.md index f9c31e79a..8b0735099 100644 --- a/docs/topics/funding.md +++ b/docs/topics/funding.md @@ -340,7 +340,7 @@ For further enquires please contact From 4a200d5e66e093ae6f8c6e94eb749ed588849ce0 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Dec 2017 10:33:48 +0100 Subject: [PATCH 214/217] Fix `override_settings` compat (#5668) * Add test checking override_settings compat * Refresh APISettings, rather than replace Fix suggested by @daggaz https://github.com/encode/django-rest-framework/issues/2466#issuecomment-344297213 --- rest_framework/settings.py | 14 +++++++++++--- tests/test_settings.py | 21 +++++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/rest_framework/settings.py b/rest_framework/settings.py index d9e3a2942..478a5229f 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -200,6 +200,7 @@ class APISettings(object): self._user_settings = self.__check_user_settings(user_settings) self.defaults = defaults or DEFAULTS self.import_strings = import_strings or IMPORT_STRINGS + self._cached_attrs = set() @property def user_settings(self): @@ -223,6 +224,7 @@ class APISettings(object): val = perform_import(val, attr) # Cache the result + self._cached_attrs.add(attr) setattr(self, attr, val) return val @@ -233,15 +235,21 @@ class APISettings(object): raise RuntimeError("The '%s' setting has been removed. Please refer to '%s' for available settings." % (setting, SETTINGS_DOC)) return user_settings + def reload(self): + for attr in self._cached_attrs: + delattr(self, attr) + self._cached_attrs.clear() + if hasattr(self, '_user_settings'): + delattr(self, '_user_settings') + api_settings = APISettings(None, DEFAULTS, IMPORT_STRINGS) def reload_api_settings(*args, **kwargs): - global api_settings - setting, value = kwargs['setting'], kwargs['value'] + setting = kwargs['setting'] if setting == 'REST_FRAMEWORK': - api_settings = APISettings(value, DEFAULTS, IMPORT_STRINGS) + api_settings.reload() setting_changed.connect(reload_api_settings) diff --git a/tests/test_settings.py b/tests/test_settings.py index 9ba552d28..51e9751b2 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,8 +1,8 @@ from __future__ import unicode_literals -from django.test import TestCase +from django.test import TestCase, override_settings -from rest_framework.settings import APISettings +from rest_framework.settings import APISettings, api_settings class TestSettings(TestCase): @@ -28,6 +28,23 @@ class TestSettings(TestCase): 'MAX_PAGINATE_BY': 100 }) + def test_compatibility_with_override_settings(self): + """ + Ref #5658 & #2466: Documented usage of api_settings + is bound at import time: + + from rest_framework.settings import api_settings + + setting_changed signal hook must ensure bound instance + is refreshed. + """ + assert api_settings.PAGE_SIZE is None, "Checking a known default should be None" + + with override_settings(REST_FRAMEWORK={'PAGE_SIZE': 10}): + assert api_settings.PAGE_SIZE == 10, "Setting should have been updated" + + assert api_settings.PAGE_SIZE is None, "Setting should have been restored" + class TestSettingTypes(TestCase): def test_settings_consistently_coerced_to_list(self): From 791539acecb801f3830948dea727f459cbd4b122 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Dec 2017 11:24:21 +0100 Subject: [PATCH 215/217] Add DEFAULT_SCHEMA_CLASS setting (#5658) * Add test for new setting * Add DefaultSchema utility * Add new setting to docs --- docs/api-guide/settings.md | 6 ++++++ rest_framework/schemas/__init__.py | 2 +- rest_framework/schemas/inspectors.py | 11 +++++++++++ rest_framework/settings.py | 4 ++++ rest_framework/views.py | 4 ++-- tests/test_schemas.py | 17 +++++++++++++++++ 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index 5c9eaa12c..a8abd2a63 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -94,6 +94,12 @@ A content negotiation class, that determines how a renderer is selected for the Default: `'rest_framework.negotiation.DefaultContentNegotiation'` +#### DEFAULT_SCHEMA_CLASS + +A view inspector class that will be used for schema generation. + +Default: `'rest_framework.schemas.AutoSchema'` + --- ## Generic view settings diff --git a/rest_framework/schemas/__init__.py b/rest_framework/schemas/__init__.py index 1af0b9fc5..ba0ec6536 100644 --- a/rest_framework/schemas/__init__.py +++ b/rest_framework/schemas/__init__.py @@ -23,7 +23,7 @@ Other access should target the submodules directly from rest_framework.settings import api_settings from .generators import SchemaGenerator -from .inspectors import AutoSchema, ManualSchema # noqa +from .inspectors import AutoSchema, DefaultSchema, ManualSchema # noqa def get_schema_view( diff --git a/rest_framework/schemas/inspectors.py b/rest_framework/schemas/inspectors.py index 008d7c091..b2a5320bd 100644 --- a/rest_framework/schemas/inspectors.py +++ b/rest_framework/schemas/inspectors.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ inspectors.py # Per-endpoint view introspection @@ -456,3 +457,13 @@ class ManualSchema(ViewInspector): ) return self._link + + +class DefaultSchema(object): + """Allows overriding AutoSchema using DEFAULT_SCHEMA_CLASS setting""" + def __get__(self, instance, owner): + inspector_class = api_settings.DEFAULT_SCHEMA_CLASS + assert issubclass(inspector_class, ViewInspector), "DEFAULT_SCHEMA_CLASS must be set to a ViewInspector (usually an AutoSchema) subclass" + inspector = inspector_class() + inspector.view = instance + return inspector diff --git a/rest_framework/settings.py b/rest_framework/settings.py index 478a5229f..db92b7a7b 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -55,6 +55,9 @@ DEFAULTS = { 'DEFAULT_PAGINATION_CLASS': None, 'DEFAULT_FILTER_BACKENDS': (), + # Schema + 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema', + # Throttling 'DEFAULT_THROTTLE_RATES': { 'user': None, @@ -140,6 +143,7 @@ IMPORT_STRINGS = ( 'DEFAULT_VERSIONING_CLASS', 'DEFAULT_PAGINATION_CLASS', 'DEFAULT_FILTER_BACKENDS', + 'DEFAULT_SCHEMA_CLASS', 'EXCEPTION_HANDLER', 'TEST_REQUEST_RENDERER_CLASSES', 'UNAUTHENTICATED_USER', diff --git a/rest_framework/views.py b/rest_framework/views.py index 3140bb9a3..f9ee7fb53 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -18,7 +18,7 @@ from django.views.generic import View from rest_framework import exceptions, status from rest_framework.request import Request from rest_framework.response import Response -from rest_framework.schemas import AutoSchema +from rest_framework.schemas import DefaultSchema from rest_framework.settings import api_settings from rest_framework.utils import formatting @@ -117,7 +117,7 @@ class APIView(View): # Allow dependency injection of other settings to make testing easier. settings = api_settings - schema = AutoSchema() + schema = DefaultSchema() @classmethod def as_view(cls, **initkwargs): diff --git a/tests/test_schemas.py b/tests/test_schemas.py index ba561a959..fa91bac03 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -516,6 +516,11 @@ class Test4605Regression(TestCase): assert prefix == '/' +class CustomViewInspector(AutoSchema): + """A dummy AutoSchema subclass""" + pass + + class TestAutoSchema(TestCase): def test_apiview_schema_descriptor(self): @@ -523,6 +528,18 @@ class TestAutoSchema(TestCase): assert hasattr(view, 'schema') assert isinstance(view.schema, AutoSchema) + def test_set_custom_inspector_class_on_view(self): + class CustomView(APIView): + schema = CustomViewInspector() + + view = CustomView() + assert isinstance(view.schema, CustomViewInspector) + + def test_set_custom_inspector_class_via_settings(self): + with override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'tests.test_schemas.CustomViewInspector'}): + view = APIView() + assert isinstance(view.schema, CustomViewInspector) + def test_get_link_requires_instance(self): descriptor = APIView.schema # Accessed from class with pytest.raises(AssertionError): From 2359d3981b0480fc850a784499a870353a7f2b8c Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 14 Dec 2017 11:39:54 +0100 Subject: [PATCH 216/217] Add docs note re generated BooleanField being `required=False` (#5665) * Note that BooleanField default is required=False Closes #5664 --- docs/api-guide/fields.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 8d61f2cbc..a8a1865a4 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -124,6 +124,8 @@ A boolean representation. When using HTML encoded form input be aware that omitting a value will always be treated as setting a field to `False`, even if it has a `default=True` option specified. This is because HTML checkbox inputs represent the unchecked state by omitting the value, so REST framework treats omission as if it is an empty checkbox input. +Note that default `BooleanField` instances will be generated with a `required=False` option (since Django `models.BooleanField` is always `blank=True`). If you want to change this behaviour explicitly declare the `BooleanField` on the serializer class. + Corresponds to `django.db.models.fields.BooleanField`. **Signature:** `BooleanField()` From d12005cf902e3969b5002593eab83bb63feda840 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Thu, 14 Dec 2017 05:48:03 -0500 Subject: [PATCH 217/217] Add 'dist' build (#5656) --- .travis.yml | 11 ++++++++++- runtests.py | 16 ++++++++++++++-- tox.ini | 10 +++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5a15140d..f503eb5e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,19 @@ matrix: - { python: "3.6", env: DJANGO=2.0 } - { python: "2.7", env: TOXENV=lint } - { python: "2.7", env: TOXENV=docs } - - python: "2.7" + + - python: "3.6" + env: TOXENV=dist + script: + - python setup.py bdist_wheel + - tox --installpkg ./dist/djangorestframework-*.whl + - tox # test sdist + + - python: "3.6" env: TOXENV=readme addons: apt_packages: pandoc + exclude: - { python: "2.7", env: DJANGO=master } - { python: "2.7", env: DJANGO=2.0 } diff --git a/runtests.py b/runtests.py index 5e8460c85..a8f818ad7 100755 --- a/runtests.py +++ b/runtests.py @@ -16,8 +16,6 @@ FLAKE8_ARGS = ['rest_framework', 'tests'] ISORT_ARGS = ['--recursive', '--check-only', '-o' 'uritemplate', '-p', 'tests', 'rest_framework', 'tests'] -sys.path.append(os.path.dirname(__file__)) - def exit_on_failure(ret, message=None): if ret: @@ -84,6 +82,20 @@ if __name__ == "__main__": run_flake8 = False run_isort = False + try: + # Remove the package root directory from `sys.path`, ensuring that rest_framework + # is imported from the installed site packages. Used for testing the distribution + sys.argv.remove('--no-pkgroot') + except ValueError: + pass + else: + sys.path.pop(0) + + # import rest_framework before pytest re-adds the package root directory. + import rest_framework + package_dir = os.path.join(os.getcwd(), 'rest_framework') + assert not rest_framework.__file__.startswith(package_dir) + if len(sys.argv) > 1: pytest_args = sys.argv[1:] first_arg = pytest_args[0] diff --git a/tox.ini b/tox.ini index e2d7aa448..f04e6ba93 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envlist = {py27,py34,py35,py36}-django111, {py34,py35,py36}-django20, {py35,py36}-djangomaster, - lint,docs,readme, + dist,lint,docs,readme, [travis:env] DJANGO = @@ -18,6 +18,7 @@ DJANGO = [testenv] commands = ./runtests.py --fast {posargs} --coverage -rw +envdir = {toxworkdir}/venvs/{envname} setenv = PYTHONDONTWRITEBYTECODE=1 PYTHONWARNINGS=once @@ -29,6 +30,13 @@ deps = -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt +[testenv:dist] +commands = ./runtests.py --fast {posargs} --no-pkgroot -rw +deps = + django + -rrequirements/requirements-testing.txt + -rrequirements/requirements-optionals.txt + [testenv:lint] basepython = python2.7 commands = ./runtests.py --lintonly