This commit is contained in:
Asif Saif Uddin 2019-03-31 08:44:45 +06:00
commit 30dc38bc8b
7 changed files with 8 additions and 12 deletions

View File

@ -51,7 +51,7 @@ For example:
--- ---
**Note**: With the exception of `DjangoObjectPermissions`, the provided **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. methods necessary to check object permissions.
If you wish to use the provided permission classes in order to check object If you wish to use the provided permission classes in order to check object

View File

@ -20,7 +20,7 @@ can render the schema into the commonly used YAML-based OpenAPI format.
## Quickstart ## 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 ### Generating a schema with the `generateschema` management command

View File

@ -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.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser from rest_framework.parsers import JSONParser
from snippets.models import Snippet from snippets.models import Snippet
from snippets.serializers import SnippetSerializer from snippets.serializers import SnippetSerializer

View File

@ -106,8 +106,7 @@ def get_field_kwargs(field_name, model_field):
if model_field.null and not isinstance(model_field, models.NullBooleanField): if model_field.null and not isinstance(model_field, models.NullBooleanField):
kwargs['allow_null'] = True kwargs['allow_null'] = True
if model_field.blank and (isinstance(model_field, models.CharField) or if model_field.blank and (isinstance(model_field, (models.CharField, models.TextField))):
isinstance(model_field, models.TextField)):
kwargs['allow_blank'] = True kwargs['allow_blank'] = True
if isinstance(model_field, models.FilePathField): 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, # Ensure that max_length is passed explicitly as a keyword arg,
# rather than as a validator. # rather than as a validator.
max_length = getattr(model_field, 'max_length', None) max_length = getattr(model_field, 'max_length', None)
if max_length is not None and (isinstance(model_field, models.CharField) or if max_length is not None and (isinstance(model_field, (models.CharField, models.TextField, models.FileField))):
isinstance(model_field, models.TextField) or
isinstance(model_field, models.FileField)):
kwargs['max_length'] = max_length kwargs['max_length'] = max_length
validator_kwarg = [ validator_kwarg = [
validator for validator in validator_kwarg validator for validator in validator_kwarg

View File

@ -633,7 +633,7 @@ class BrowsableAPIRendererTests(URLPatternsTestCase):
raise NotImplementedError raise NotImplementedError
router = SimpleRouter() router = SimpleRouter()
router.register('examples', ExampleViewSet, base_name='example') router.register('examples', ExampleViewSet, basename='example')
urlpatterns = [url(r'^api/', include(router.urls))] urlpatterns = [url(r'^api/', include(router.urls))]
def setUp(self): def setUp(self):

View File

@ -119,7 +119,7 @@ class BasicViewSet(viewsets.ViewSet):
class TestSimpleRouter(URLPatternsTestCase, TestCase): class TestSimpleRouter(URLPatternsTestCase, TestCase):
router = SimpleRouter() router = SimpleRouter()
router.register('basics', BasicViewSet, base_name='basic') router.register('basics', BasicViewSet, basename='basic')
urlpatterns = [ urlpatterns = [
url(r'^api/', include(router.urls)), url(r'^api/', include(router.urls)),

View File

@ -25,7 +25,7 @@ deps =
django111: Django>=1.11,<2.0 django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1 django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2 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 djangomaster: https://github.com/django/django/archive/master.tar.gz
-rrequirements/requirements-testing.txt -rrequirements/requirements-testing.txt
-rrequirements/requirements-optionals.txt -rrequirements/requirements-optionals.txt