From b25d245b893ce0a04c9ed33a12ebf6a6a1ff6b44 Mon Sep 17 00:00:00 2001 From: Patrickcai Date: Fri, 22 Mar 2019 20:29:45 +0800 Subject: [PATCH 1/5] Merge multiple isinstance() calls to one (#6513) * Merge multiple isinstance() calls to one See https://docs.python.org/3/library/functions.html#isinstance * Fix `)` mismatch Fix `)` mismatch --- rest_framework/utils/field_mapping.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rest_framework/utils/field_mapping.py b/rest_framework/utils/field_mapping.py index f11b4b94e..927d08ff2 100644 --- a/rest_framework/utils/field_mapping.py +++ b/rest_framework/utils/field_mapping.py @@ -106,8 +106,7 @@ def get_field_kwargs(field_name, model_field): if model_field.null and not isinstance(model_field, models.NullBooleanField): kwargs['allow_null'] = True - if model_field.blank and (isinstance(model_field, models.CharField) or - isinstance(model_field, models.TextField)): + if model_field.blank and (isinstance(model_field, (models.CharField, models.TextField))): kwargs['allow_blank'] = True if isinstance(model_field, models.FilePathField): @@ -193,9 +192,7 @@ def get_field_kwargs(field_name, model_field): # Ensure that max_length is passed explicitly as a keyword arg, # rather than as a validator. max_length = getattr(model_field, 'max_length', None) - if max_length is not None and (isinstance(model_field, models.CharField) or - isinstance(model_field, models.TextField) or - isinstance(model_field, models.FileField)): + if max_length is not None and (isinstance(model_field, (models.CharField, models.TextField, models.FileField))): kwargs['max_length'] = max_length validator_kwarg = [ validator for validator in validator_kwarg From d784e4220762bd8efa6c99887ef1a1c43b51d52c Mon Sep 17 00:00:00 2001 From: Turfa Auliarachman Date: Tue, 26 Mar 2019 00:42:27 +0700 Subject: [PATCH 2/5] Fix `basename` deprecation warnings in tests (#6529) --- tests/test_renderers.py | 2 +- tests/test_routers.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_renderers.py b/tests/test_renderers.py index b4c41b148..60a0c0307 100644 --- a/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -636,7 +636,7 @@ class BrowsableAPIRendererTests(URLPatternsTestCase): raise NotImplementedError router = SimpleRouter() - router.register('examples', ExampleViewSet, base_name='example') + router.register('examples', ExampleViewSet, basename='example') urlpatterns = [url(r'^api/', include(router.urls))] def setUp(self): diff --git a/tests/test_routers.py b/tests/test_routers.py index a3a731f93..cca2ea712 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -121,7 +121,7 @@ class BasicViewSet(viewsets.ViewSet): class TestSimpleRouter(URLPatternsTestCase, TestCase): router = SimpleRouter() - router.register('basics', BasicViewSet, base_name='basic') + router.register('basics', BasicViewSet, basename='basic') urlpatterns = [ url(r'^api/', include(router.urls)), From ac19c695396cdd0a72b81dc5fece7a850ae3d1b2 Mon Sep 17 00:00:00 2001 From: Jabi Date: Thu, 28 Mar 2019 11:45:13 +0100 Subject: [PATCH 3/5] Corrected typo in permissions docs. (#6540) --- 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 6a1297e60..901f810c5 100644 --- a/docs/api-guide/permissions.md +++ b/docs/api-guide/permissions.md @@ -51,7 +51,7 @@ For example: --- **Note**: With the exception of `DjangoObjectPermissions`, the provided -permission classes in `rest_framework.permssions` **do not** implement the +permission classes in `rest_framework.permissions` **do not** implement the methods necessary to check object permissions. If you wish to use the provided permission classes in order to check object From 13b9b0fb98b58c867fa3ef625d75b6835b9c3b70 Mon Sep 17 00:00:00 2001 From: Asif Saif Uddin Date: Fri, 29 Mar 2019 02:19:06 +0600 Subject: [PATCH 4/5] Upgraded to Django 2.2rc1 on Tox (#6544) --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4226f1a92..776af3b6e 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,7 @@ deps = django111: Django>=1.11,<2.0 django20: Django>=2.0,<2.1 django21: Django>=2.1,<2.2 - django22: Django>=2.2b1,<3.0 + django22: Django>=2.2rc1,<3.0 djangomaster: https://github.com/django/django/archive/master.tar.gz -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt From f34a0a4e6a4de5d58c7abd365bd2343c228eb915 Mon Sep 17 00:00:00 2001 From: Matt Hegarty Date: Fri, 29 Mar 2019 06:32:25 +0000 Subject: [PATCH 5/5] Minor documentation fixes (#6543) --- docs/api-guide/schemas.md | 2 +- docs/tutorial/1-serialization.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 3d07ed621..b09b1606e 100644 --- a/docs/api-guide/schemas.md +++ b/docs/api-guide/schemas.md @@ -20,7 +20,7 @@ can render the schema into the commonly used YAML-based OpenAPI format. ## Quickstart -There are two different ways you can serve a schema description for you API. +There are two different ways you can serve a schema description for your API. ### Generating a schema with the `generateschema` management command diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md index 07ee8f208..224ebf25b 100644 --- a/docs/tutorial/1-serialization.md +++ b/docs/tutorial/1-serialization.md @@ -8,7 +8,7 @@ The tutorial is fairly in-depth, so you should probably get a cookie and a cup o --- -**Note**: The code for this tutorial is available in the [tomchristie/rest-framework-tutorial][repo] repository on GitHub. The completed implementation is also online as a sandbox version for testing, [available here][sandbox]. +**Note**: The code for this tutorial is available in the [encode/rest-framework-tutorial][repo] repository on GitHub. The completed implementation is also online as a sandbox version for testing, [available here][sandbox]. --- @@ -218,7 +218,6 @@ Edit the `snippets/views.py` file, and add the following. from django.http import HttpResponse, JsonResponse from django.views.decorators.csrf import csrf_exempt - from rest_framework.renderers import JSONRenderer from rest_framework.parsers import JSONParser from snippets.models import Snippet from snippets.serializers import SnippetSerializer