mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 01:49:50 +03:00
Merge branch 'master' of https://github.com/encode/django-rest-framework into py2
This commit is contained in:
commit
30dc38bc8b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -633,7 +633,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):
|
||||
|
|
|
@ -119,7 +119,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)),
|
||||
|
|
2
tox.ini
2
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user