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/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] diff --git a/README.md b/README.md index 814da6e92..87e5e3da5 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ There is a live example API for testing purposes, [available here][sandbox]. # Requirements -* Python (2.7, 3.2, 3.3, 3.4, 3.5, 3.6) -* Django (1.8, 1.9, 1.10, 1.11) +* Python (2.7, 3.4, 3.5, 3.6) +* Django (1.10, 1.11) # Installation diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 538ac0a3c..5f8819e11 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -436,7 +436,7 @@ Requires either the `Pillow` package or `PIL` package. The `Pillow` package is A field class that validates a list of objects. -**Signature**: `ListField(child, min_length=None, max_length=None)` +**Signature**: `ListField(child=, min_length=None, max_length=None)` - `child` - A field instance that should be used for validating the objects in the list. If this argument is not provided then objects in the list will not be validated. - `min_length` - Validates that the list contains no fewer than this number of elements. @@ -459,7 +459,7 @@ We can now reuse our custom `StringListField` class throughout our application, A field class that validates a dictionary of objects. The keys in `DictField` are always assumed to be string values. -**Signature**: `DictField(child)` +**Signature**: `DictField(child=)` - `child` - A field instance that should be used for validating the values in the dictionary. If this argument is not provided then values in the mapping will not be validated. 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. diff --git a/docs/api-guide/pagination.md b/docs/api-guide/pagination.md index d767e45de..b28f1616d 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', @@ -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. @@ -226,8 +230,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 @@ -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 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 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 diff --git a/docs/api-guide/schemas.md b/docs/api-guide/schemas.md index 836ad4b6a..2cb29d5f8 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,127 @@ 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. + +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 +`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 @@ -193,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 @@ -342,38 +492,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 +530,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/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 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. 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 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 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. diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 4fa36d0fc..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 @@ -184,6 +178,35 @@ 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]. +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 [settings]: settings.md 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: '' }) diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 7bdd7b0b1..beede65d6 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -38,8 +38,120 @@ You can determine your currently installed version using `pip freeze`: --- +## 3.7.x series + +### 3.7.0 + +* 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. [#5435][gh5435] + + 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. + +* Removed DjangoFilterBackend inline with deprecation policy. Use `django_filters.rest_framework.FilterSet` and/or `django_filters.rest_framework.DjangoFilterBackend` instead. [#5273][gh5273] +* Don't strip microseconds from `time` when encoding. Makes consistent with `datetime`. + **BC Change**: Previously only milliseconds were encoded. [#5440][gh5440] +* Added `STRICT_JSON` setting (default `True`) to raise exception for the extended float values (`nan`, `inf`, `-inf`) accepted by Python's `json` module. + **BC Change**: Previously these values would converted to corresponding strings. Set `STRICT_JSON` to `False` to restore the previous behaviour. [#5265][gh5265] +* Add support for `page_size` parameter in CursorPaginator class [#5250][gh5250] +* Make `DEFAULT_PAGINATION_CLASS` `None` by default. + **BC Change**: If your were **just** setting `PAGE_SIZE` to enable pagination you will need to add `DEFAULT_PAGINATION_CLASS`. + The previous default was `rest_framework.pagination.PageNumberPagination`. There is a system check warning to catch this case. You may silence that if you are setting pagination class on a per-view basis. [#5170][gh5170] +* Catch `APIException` from `get_serializer_fields` in schema generation. [#5443][gh5443] +* Allow custom authentication and permission classes when using `include_docs_urls` [#5448][gh5448] +* Defer translated string evaluation on validators. [#5452][gh5452] +* Added default value for 'detail' param into 'ValidationError' exception [#5342][gh5342] +* Adjust schema get_filter_fields rules to match framework [#5454][gh5454] +* Updated test matrix to add Django 2.0 and drop Django 1.8 & 1.9 + **BC Change**: This removes Django 1.8 and Django 1.9 from Django REST Framework supported versions. [#5457][gh5457] +* Fixed a deprecation warning in serializers.ModelField [#5058][gh5058] +* Added a more explicit error message when `get_queryset` returned `None` [#5348][gh5348] +* Fix docs for Response `data` description [#5361][gh5361] +* Fix __pychache__/.pyc excludes when packaging [#5373][gh5373] +* Fix default value handling for dotted sources [#5375][gh5375] +* Ensure content_type is set when passing empty body to RequestFactory [#5351][gh5351] +* Fix ErrorDetail Documentation [#5380][gh5380] +* Allow optional content in the generic content form [#5372][gh5372] +* Updated supported values for the NullBooleanField [#5387][gh5387] +* Fix ModelSerializer custom named fields with source on model [#5388][gh5388] +* Fixed the MultipleFieldLookupMixin documentation example to properly check for object level permission [#5398][gh5398] +* Update get_object() example in permissions.md [#5401][gh5401] +* Fix authtoken managment command [#5415][gh5415] +* Fix schema generation markdown [#5421][gh5421] +* Allow `ChoiceField.choices` to be set dynamically [#5426][gh5426] +* Add the project layout to the quickstart [#5434][gh5434] + + + + +[gh5435]: https://github.com/encode/django-rest-framework/issues/5435 +[gh5434]: https://github.com/encode/django-rest-framework/issues/5434 +[gh5426]: https://github.com/encode/django-rest-framework/issues/5426 +[gh5421]: https://github.com/encode/django-rest-framework/issues/5421 +[gh5415]: https://github.com/encode/django-rest-framework/issues/5415 +[gh5401]: https://github.com/encode/django-rest-framework/issues/5401 +[gh5398]: https://github.com/encode/django-rest-framework/issues/5398 +[gh5388]: https://github.com/encode/django-rest-framework/issues/5388 +[gh5387]: https://github.com/encode/django-rest-framework/issues/5387 +[gh5372]: https://github.com/encode/django-rest-framework/issues/5372 +[gh5380]: https://github.com/encode/django-rest-framework/issues/5380 +[gh5351]: https://github.com/encode/django-rest-framework/issues/5351 +[gh5375]: https://github.com/encode/django-rest-framework/issues/5375 +[gh5373]: https://github.com/encode/django-rest-framework/issues/5373 +[gh5361]: https://github.com/encode/django-rest-framework/issues/5361 +[gh5348]: https://github.com/encode/django-rest-framework/issues/5348 +[gh5058]: https://github.com/encode/django-rest-framework/issues/5058 +[gh5457]: https://github.com/encode/django-rest-framework/issues/5457 +[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 +[gh5273]: https://github.com/encode/django-rest-framework/issues/5273 +[gh5440]: https://github.com/encode/django-rest-framework/issues/5440 +[gh5265]: https://github.com/encode/django-rest-framework/issues/5265 +[gh5250]: https://github.com/encode/django-rest-framework/issues/5250 +[gh5170]: https://github.com/encode/django-rest-framework/issues/5170 +[gh5443]: https://github.com/encode/django-rest-framework/issues/5443 +[gh5448]: https://github.com/encode/django-rest-framework/issues/5448 +[gh5452]: https://github.com/encode/django-rest-framework/issues/5452 +[gh5342]: https://github.com/encode/django-rest-framework/issues/5342 +[gh5454]: https://github.com/encode/django-rest-framework/issues/5454 + + ## 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] +* Fix/remove undefined template var "schema" [#5346][gh5346] + ### 3.6.3 **Date**: [12th May 2017][3.6.3-milestone] @@ -716,6 +828,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 +1439,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 +1473,30 @@ 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 + + +[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 +[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 + 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) 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 diff --git a/requirements/requirements-codestyle.txt b/requirements/requirements-codestyle.txt index 264416f5f..a64cfa29f 100644 --- a/requirements/requirements-codestyle.txt +++ b/requirements/requirements-codestyle.txt @@ -1,6 +1,7 @@ # PEP8 code linting, which we run on all commits. -flake8==2.4.0 -pep8==1.5.7 +flake8==3.4.1 +flake8-tidy-imports==1.1.0 +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 e8ba50851..67525bebc 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -1,6 +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/rest_framework/__init__.py b/rest_framework/__init__.py index c0b5c4c04..bc4ddff06 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.7.0' __author__ = 'Tom Christie' __license__ = 'BSD 2-Clause' __copyright__ = 'Copyright 2011-2017 Tom Christie' @@ -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/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/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/compat.py b/rest_framework/compat.py index 168bccf83..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 @@ -182,13 +187,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 @@ -300,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/decorators.py b/rest_framework/decorators.py index bf9b32aaa..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 @@ -72,7 +73,17 @@ def api_view(http_method_names=None, exclude_from_schema=False): WrappedAPIView.permission_classes = getattr(func, 'permission_classes', APIView.permission_classes) - WrappedAPIView.exclude_from_schema = exclude_from_schema + WrappedAPIView.schema = getattr(func, 'schema', + APIView.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 @@ -112,6 +123,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/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/exceptions.py b/rest_framework/exceptions.py index aac31c453..12fd41931 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 @@ -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: diff --git a/rest_framework/fields.py b/rest_framework/fields.py index e887ca306..d02332886 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 @@ -14,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 @@ -28,18 +26,20 @@ from django.utils.encoding import is_protected_type, smart_text from django.utils.formats import ( localize_input, number_format, 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 -from rest_framework.utils import html, humanize_datetime, representation +from rest_framework.utils import html, humanize_datetime, json, representation class empty: @@ -95,9 +95,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] @@ -144,7 +141,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] @@ -693,8 +690,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): @@ -703,12 +714,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): @@ -739,11 +753,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, @@ -898,11 +918,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: @@ -936,11 +962,17 @@ class FloatField(Field): self.coerce_to_string = True 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): @@ -1000,11 +1032,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): """ @@ -1128,7 +1166,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: @@ -1138,7 +1178,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) @@ -1177,6 +1217,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' @@ -1340,18 +1381,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) @@ -1380,6 +1413,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 = { @@ -1790,13 +1839,16 @@ 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) 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): 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/rest_framework/locale/ar/LC_MESSAGES/django.mo b/rest_framework/locale/ar/LC_MESSAGES/django.mo index 06471de23..bda2ce995 100644 Binary files a/rest_framework/locale/ar/LC_MESSAGES/django.mo and b/rest_framework/locale/ar/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/ca/LC_MESSAGES/django.mo index 7418c1ed0..28faf17ff 100644 Binary files a/rest_framework/locale/ca/LC_MESSAGES/django.mo and b/rest_framework/locale/ca/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/cs/LC_MESSAGES/django.mo index 1c98eb62d..4352fb091 100644 Binary files a/rest_framework/locale/cs/LC_MESSAGES/django.mo and b/rest_framework/locale/cs/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/da/LC_MESSAGES/django.mo index 9c17c3a40..1983e068f 100644 Binary files a/rest_framework/locale/da/LC_MESSAGES/django.mo and b/rest_framework/locale/da/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/de/LC_MESSAGES/django.mo index 317124886..eb0ddf66d 100644 Binary files a/rest_framework/locale/de/LC_MESSAGES/django.mo and b/rest_framework/locale/de/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/el/LC_MESSAGES/django.mo index c7fb97b2c..d275dba3b 100644 Binary files a/rest_framework/locale/el/LC_MESSAGES/django.mo and b/rest_framework/locale/el/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/es/LC_MESSAGES/django.mo index 1ddc885de..372bf6bf6 100644 Binary files a/rest_framework/locale/es/LC_MESSAGES/django.mo and b/rest_framework/locale/es/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/et/LC_MESSAGES/django.mo index 8bed39930..eaadf454b 100644 Binary files a/rest_framework/locale/et/LC_MESSAGES/django.mo and b/rest_framework/locale/et/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/fi/LC_MESSAGES/django.mo index cb13cdaae..e0231cfb3 100644 Binary files a/rest_framework/locale/fi/LC_MESSAGES/django.mo and b/rest_framework/locale/fi/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/fr/LC_MESSAGES/django.mo index 2bc60c63a..e3ba4a2c5 100644 Binary files a/rest_framework/locale/fr/LC_MESSAGES/django.mo and b/rest_framework/locale/fr/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/hu/LC_MESSAGES/django.mo index cb27fb740..8b884fbed 100644 Binary files a/rest_framework/locale/hu/LC_MESSAGES/django.mo and b/rest_framework/locale/hu/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/it/LC_MESSAGES/django.mo index 5d52d3dcf..a9510eb89 100644 Binary files a/rest_framework/locale/it/LC_MESSAGES/django.mo and b/rest_framework/locale/it/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/ja/LC_MESSAGES/django.mo index 1f934cc37..9ce42cfb3 100644 Binary files a/rest_framework/locale/ja/LC_MESSAGES/django.mo and b/rest_framework/locale/ja/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/ko_KR/LC_MESSAGES/django.mo index 6410f0b1c..f83b7ed71 100644 Binary files a/rest_framework/locale/ko_KR/LC_MESSAGES/django.mo and b/rest_framework/locale/ko_KR/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/lv/LC_MESSAGES/django.mo new file mode 100644 index 000000000..2dc5956f3 Binary files /dev/null and b/rest_framework/locale/lv/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/mk/LC_MESSAGES/django.mo index ac9a48193..ae9956f25 100644 Binary files a/rest_framework/locale/mk/LC_MESSAGES/django.mo and b/rest_framework/locale/mk/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/nb/LC_MESSAGES/django.mo index d3dfe100a..d942abc2c 100644 Binary files a/rest_framework/locale/nb/LC_MESSAGES/django.mo and b/rest_framework/locale/nb/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/nl/LC_MESSAGES/django.mo index 8f9c2dcde..782bf1634 100644 Binary files a/rest_framework/locale/nl/LC_MESSAGES/django.mo and b/rest_framework/locale/nl/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/pl/LC_MESSAGES/django.mo index 8af27437f..99840f55c 100644 Binary files a/rest_framework/locale/pl/LC_MESSAGES/django.mo and b/rest_framework/locale/pl/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/pt_BR/LC_MESSAGES/django.mo index 1dd7287f3..482c07cdb 100644 Binary files a/rest_framework/locale/pt_BR/LC_MESSAGES/django.mo and b/rest_framework/locale/pt_BR/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/ro/LC_MESSAGES/django.mo index 5a113ab72..6a8ada9a7 100644 Binary files a/rest_framework/locale/ro/LC_MESSAGES/django.mo and b/rest_framework/locale/ro/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/ru/LC_MESSAGES/django.mo index be0620a33..88c582b13 100644 Binary files a/rest_framework/locale/ru/LC_MESSAGES/django.mo and b/rest_framework/locale/ru/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/sk/LC_MESSAGES/django.mo index dda693e32..83d43c822 100644 Binary files a/rest_framework/locale/sk/LC_MESSAGES/django.mo and b/rest_framework/locale/sk/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/sl/LC_MESSAGES/django.mo new file mode 100644 index 000000000..9ac13843f Binary files /dev/null and b/rest_framework/locale/sl/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/sv/LC_MESSAGES/django.mo index cbecec44d..232b5bcee 100644 Binary files a/rest_framework/locale/sv/LC_MESSAGES/django.mo and b/rest_framework/locale/sv/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/tr/LC_MESSAGES/django.mo index 818aad279..586b494c3 100644 Binary files a/rest_framework/locale/tr/LC_MESSAGES/django.mo and b/rest_framework/locale/tr/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/tr_TR/LC_MESSAGES/django.mo index a3a8ca0d5..c0665f537 100644 Binary files a/rest_framework/locale/tr_TR/LC_MESSAGES/django.mo and b/rest_framework/locale/tr_TR/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/uk/LC_MESSAGES/django.mo index bfcb776e7..0c8102088 100644 Binary files a/rest_framework/locale/uk/LC_MESSAGES/django.mo and b/rest_framework/locale/uk/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/zh_CN/LC_MESSAGES/django.mo index 5ba81a865..00afcdb9a 100644 Binary files a/rest_framework/locale/zh_CN/LC_MESSAGES/django.mo and b/rest_framework/locale/zh_CN/LC_MESSAGES/django.mo differ 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.mo b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo index 396aded07..a784846b2 100644 Binary files a/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo and b/rest_framework/locale/zh_Hans/LC_MESSAGES/django.mo differ 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." 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/rest_framework/parsers.py b/rest_framework/parsers.py index 0e40e1a7a..7a256276a 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,8 @@ 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 class DataAndFiles(object): @@ -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/permissions.py b/rest_framework/permissions.py index f24775278..dee0032f9 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -114,29 +114,35 @@ 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. if getattr(view, '_ignore_model_permissions', False): return True - if hasattr(view, 'get_queryset'): - queryset = view.get_queryset() - 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.' - ) + if not request.user or ( + not is_authenticated(request.user) and self.authenticated_users_only): + return False + queryset = self._queryset(view) 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): @@ -180,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/rest_framework/renderers.py b/rest_framework/renderers.py index 779f0dd44..90f516b35 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 @@ -62,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. @@ -102,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, @@ -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() 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/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): diff --git a/rest_framework/routers.py b/rest_framework/routers.py index a04bffc1a..3b5ef46d8 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 @@ -290,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/__init__.py b/rest_framework/schemas/__init__.py new file mode 100644 index 000000000..1af0b9fc5 --- /dev/null +++ b/rest_framework/schemas/__init__.py @@ -0,0 +1,49 @@ +""" +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 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, + authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES, + permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES): + """ + 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, + authentication_classes=authentication_classes, + permission_classes=permission_classes, + ) 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 875f9454b..3e927527c 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas/generators.py @@ -1,86 +1,27 @@ -import re +""" +generators.py # Top-down schema generation + +See schemas.__init__.py for package overview. +""" +import warnings 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): - 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 +45,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 +73,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 +85,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. """ @@ -236,6 +149,17 @@ class EndpointInspector(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. @@ -265,7 +189,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. @@ -327,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)) @@ -341,7 +263,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 +355,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 +400,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..30f639f5b --- /dev/null +++ b/rest_framework/schemas/inspectors.py @@ -0,0 +1,422 @@ +""" +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 exceptions, 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 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 [] + + 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(view.__class__.__name__, method, path)) + + 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 _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): + if not self._allows_filters(path, method): + return [] + + fields = [] + for filter_backend in self.view.filter_backends: + fields += filter_backend().get_schema_fields(self.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..b13eadea9 --- /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 + schema = None # exclude from schema + 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/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/rest_framework/settings.py b/rest_framework/settings.py index 3f3c9110a..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 @@ -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/rest_framework/static/rest_framework/docs/js/api.js b/rest_framework/static/rest_framework/docs/js/api.js index 3c5b7180d..2a2c835ef 100644 --- a/rest_framework/static/rest_framework/docs/js/api.js +++ b/rest_framework/static/rest_framework/docs/js/api.js @@ -2,6 +2,14 @@ var responseDisplay = 'data' var coreapi = window.coreapi var schema = window.schema +function normalizeKeys (arr) { + var _normarr = []; + for (var i = 0; i < arr.length; i++) { + _normarr = _normarr.concat(arr[i].split(' > ')); + } + return _normarr; +} + function normalizeHTTPHeader (str) { // Capitalize HTTP headers for display. return (str.charAt(0).toUpperCase() + str.substring(1)) @@ -94,7 +102,7 @@ $(function () { var $requestAwaiting = $form.find('.request-awaiting') var $responseRaw = $form.find('.response-raw') var $responseData = $form.find('.response-data') - var key = $form.data('key') + var key = normalizeKeys($form.data('key')) var params = {} var entries = formEntries($form.get()[0]) @@ -212,7 +220,6 @@ $(function () { } var client = new coreapi.Client(options) - client.action(schema, key, params).then(function (data) { var response = JSON.stringify(data, null, 2) $requestAwaiting.addClass('hide') diff --git a/rest_framework/templates/rest_framework/docs/document.html b/rest_framework/templates/rest_framework/docs/document.html index 274eee4e3..7a438f68d 100644 --- a/rest_framework/templates/rest_framework/docs/document.html +++ b/rest_framework/templates/rest_framework/docs/document.html @@ -20,7 +20,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/interact.html b/rest_framework/templates/rest_framework/docs/interact.html index 3703301c2..60771ba20 100644 --- a/rest_framework/templates/rest_framework/docs/interact.html +++ b/rest_framework/templates/rest_framework/docs/interact.html @@ -1,7 +1,7 @@ {% load rest_framework %} -