Commit d8451579 by Aider Ibragimov

Merge branch 'master' of https://github.com/tomchristie/django-rest-framework…

Merge branch 'master' of https://github.com/tomchristie/django-rest-framework into feature/filepathfield
parents e5d95e31 85cc8e9f
...@@ -14,3 +14,4 @@ MANIFEST ...@@ -14,3 +14,4 @@ MANIFEST
!.gitignore !.gitignore
!.travis.yml !.travis.yml
!.isort.cfg
[settings]
skip=.tox
atomic=true
multi_line_output=5
known_third_party=pytest,django
known_first_party=rest_framework
...@@ -3,8 +3,12 @@ language: python ...@@ -3,8 +3,12 @@ language: python
sudo: false sudo: false
env: env:
- TOX_ENV=py27-flake8 - TOX_ENV=py27-lint
- TOX_ENV=py27-docs - TOX_ENV=py27-docs
- TOX_ENV=py34-django18
- TOX_ENV=py33-django18
- TOX_ENV=py32-django18
- TOX_ENV=py27-django18
- TOX_ENV=py34-django17 - TOX_ENV=py34-django17
- TOX_ENV=py33-django17 - TOX_ENV=py33-django17
- TOX_ENV=py32-django17 - TOX_ENV=py32-django17
...@@ -21,10 +25,18 @@ env: ...@@ -21,10 +25,18 @@ env:
- TOX_ENV=py26-django15 - TOX_ENV=py26-django15
- TOX_ENV=py27-django14 - TOX_ENV=py27-django14
- TOX_ENV=py26-django14 - TOX_ENV=py26-django14
- TOX_ENV=py34-django18beta - TOX_ENV=py27-djangomaster
- TOX_ENV=py33-django18beta - TOX_ENV=py32-djangomaster
- TOX_ENV=py32-django18beta - TOX_ENV=py33-djangomaster
- TOX_ENV=py27-django18beta - TOX_ENV=py34-djangomaster
matrix:
fast_finish: true
allow_failures:
- env: TOX_ENV=py27-djangomaster
- env: TOX_ENV=py32-djangomaster
- env: TOX_ENV=py33-djangomaster
- env: TOX_ENV=py34-djangomaster
install: install:
- pip install tox - pip install tox
......
# License
Copyright (c) 2011-2015, Tom Christie
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include README.md
include LICENSE.md
recursive-include rest_framework/static *.js *.css *.png *.eot *.svg *.ttf *.woff recursive-include rest_framework/static *.js *.css *.png *.eot *.svg *.ttf *.woff
recursive-include rest_framework/templates *.html recursive-include rest_framework/templates *.html
recursive-exclude * __pycache__ recursive-exclude * __pycache__
......
...@@ -9,7 +9,9 @@ Full documentation for the project is available at [http://www.django-rest-frame ...@@ -9,7 +9,9 @@ Full documentation for the project is available at [http://www.django-rest-frame
--- ---
**Note**: We have now released Django REST framework 3.0. For older codebases you may want to refer to the version 2.4.4 [source code](https://github.com/tomchristie/django-rest-framework/tree/version-2.4.x), and [documentation](http://tomchristie.github.io/rest-framework-2-docs/). **Note**: We have now released Django REST framework 3.1. For older codebases you may want to refer to the version 2.4.4 [source code](https://github.com/tomchristie/django-rest-framework/tree/version-2.4.x), and [documentation](http://tomchristie.github.io/rest-framework-2-docs/).
For more details see the [3.1 release notes][3.1-announcement]
--- ---
...@@ -23,7 +25,7 @@ Some reasons you might want to use REST framework: ...@@ -23,7 +25,7 @@ Some reasons you might want to use REST framework:
* [Authentication policies][authentication] including optional packages for [OAuth1a][oauth1-section] and [OAuth2][oauth2-section]. * [Authentication policies][authentication] including optional packages for [OAuth1a][oauth1-section] and [OAuth2][oauth2-section].
* [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources. * [Serialization][serializers] that supports both [ORM][modelserializer-section] and [non-ORM][serializer-section] data sources.
* Customizable all the way down - just use [regular function-based views][functionview-section] if you don't need the [more][generic-views] [powerful][viewsets] [features][routers]. * Customizable all the way down - just use [regular function-based views][functionview-section] if you don't need the [more][generic-views] [powerful][viewsets] [features][routers].
* [Extensive documentation][index], and [great community support][group]. * [Extensive documentation][docs], and [great community support][group].
There is a live example API for testing purposes, [available here][sandbox]. There is a live example API for testing purposes, [available here][sandbox].
...@@ -34,7 +36,7 @@ There is a live example API for testing purposes, [available here][sandbox]. ...@@ -34,7 +36,7 @@ There is a live example API for testing purposes, [available here][sandbox].
# Requirements # Requirements
* Python (2.6.5+, 2.7, 3.2, 3.3, 3.4) * Python (2.6.5+, 2.7, 3.2, 3.3, 3.4)
* Django (1.4.11+, 1.5.6+, 1.6.3+, 1.7, 1.8-beta) * Django (1.4.11+, 1.5.6+, 1.6.3+, 1.7, 1.8)
# Installation # Installation
...@@ -154,42 +156,15 @@ If you believe you’ve found something in Django REST framework which has secur ...@@ -154,42 +156,15 @@ If you believe you’ve found something in Django REST framework which has secur
Send a description of the issue via email to [rest-framework-security@googlegroups.com][security-mail]. The project maintainers will then work with you to resolve any issues where required, prior to any public disclosure. Send a description of the issue via email to [rest-framework-security@googlegroups.com][security-mail]. The project maintainers will then work with you to resolve any issues where required, prior to any public disclosure.
# License
Copyright (c) 2011-2015, Tom Christie
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[build-status-image]: https://secure.travis-ci.org/tomchristie/django-rest-framework.svg?branch=master [build-status-image]: https://secure.travis-ci.org/tomchristie/django-rest-framework.svg?branch=master
[travis]: http://travis-ci.org/tomchristie/django-rest-framework?branch=master [travis]: http://travis-ci.org/tomchristie/django-rest-framework?branch=master
[pypi-version]: https://pypip.in/version/djangorestframework/badge.svg [pypi-version]: https://img.shields.io/pypi/v/djangorestframework.svg
[pypi]: https://pypi.python.org/pypi/djangorestframework [pypi]: https://pypi.python.org/pypi/djangorestframework
[twitter]: https://twitter.com/_tomchristie [twitter]: https://twitter.com/_tomchristie
[group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework [group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
[0.4]: https://github.com/tomchristie/django-rest-framework/tree/0.4.X
[sandbox]: http://restframework.herokuapp.com/ [sandbox]: http://restframework.herokuapp.com/
[index]: http://www.django-rest-framework.org/
[oauth1-section]: http://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth [oauth1-section]: http://www.django-rest-framework.org/api-guide/authentication/#django-rest-framework-oauth
[oauth2-section]: http://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit [oauth2-section]: http://www.django-rest-framework.org/api-guide/authentication/#django-oauth-toolkit
[serializer-section]: http://www.django-rest-framework.org/api-guide/serializers/#serializers [serializer-section]: http://www.django-rest-framework.org/api-guide/serializers/#serializers
...@@ -200,18 +175,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -200,18 +175,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[routers]: http://www.django-rest-framework.org/api-guide/routers/ [routers]: http://www.django-rest-framework.org/api-guide/routers/
[serializers]: http://www.django-rest-framework.org/api-guide/serializers/ [serializers]: http://www.django-rest-framework.org/api-guide/serializers/
[authentication]: http://www.django-rest-framework.org/api-guide/authentication/ [authentication]: http://www.django-rest-framework.org/api-guide/authentication/
[rest-framework-2-announcement]: http://www.django-rest-framework.org/topics/rest-framework-2-announcement/
[2.1.0-notes]: https://groups.google.com/d/topic/django-rest-framework/Vv2M0CMY9bg/discussion
[image]: http://www.django-rest-framework.org/img/quickstart.png [image]: http://www.django-rest-framework.org/img/quickstart.png
[tox]: http://testrun.org/tox/latest/
[tehjones]: https://twitter.com/tehjones/status/294986071979196416
[wlonk]: https://twitter.com/wlonk/status/261689665952833536
[laserllama]: https://twitter.com/laserllama/status/328688333750407168
[docs]: http://www.django-rest-framework.org/ [docs]: http://www.django-rest-framework.org/
[urlobject]: https://github.com/zacharyvoase/urlobject
[markdown]: http://pypi.python.org/pypi/Markdown/
[django-filter]: http://pypi.python.org/pypi/django-filter
[security-mail]: mailto:rest-framework-security@googlegroups.com [security-mail]: mailto:rest-framework-security@googlegroups.com
[3.1-announcement]: http://www.django-rest-framework.org/topics/3.1-announcement/
...@@ -168,7 +168,6 @@ The `curl` command line tool may be useful for testing token authenticated APIs. ...@@ -168,7 +168,6 @@ The `curl` command line tool may be useful for testing token authenticated APIs.
If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal. If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal.
from django.conf import settings from django.conf import settings
from django.contrib.auth import get_user_model
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
...@@ -248,6 +247,10 @@ Unauthenticated responses that are denied permission will result in an `HTTP 403 ...@@ -248,6 +247,10 @@ Unauthenticated responses that are denied permission will result in an `HTTP 403
If you're using an AJAX style API with SessionAuthentication, you'll need to make sure you include a valid CSRF token for any "unsafe" HTTP method calls, such as `PUT`, `PATCH`, `POST` or `DELETE` requests. See the [Django CSRF documentation][csrf-ajax] for more details. If you're using an AJAX style API with SessionAuthentication, you'll need to make sure you include a valid CSRF token for any "unsafe" HTTP method calls, such as `PUT`, `PATCH`, `POST` or `DELETE` requests. See the [Django CSRF documentation][csrf-ajax] for more details.
**Warning**: Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.
CSRF validation in REST framework works slightly differently to standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behaviour is not suitable for login views, which should always have CSRF validation applied.
# Custom authentication # Custom authentication
To implement a custom authentication scheme, subclass `BaseAuthentication` and override the `.authenticate(self, request)` method. The method should return a two-tuple of `(user, auth)` if authentication succeeds, or `None` otherwise. To implement a custom authentication scheme, subclass `BaseAuthentication` and override the `.authenticate(self, request)` method. The method should return a two-tuple of `(user, auth)` if authentication succeeds, or `None` otherwise.
......
source: fields.py source: fields.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Serializer fields # Serializer fields
> Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format. > Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format.
...@@ -26,6 +20,8 @@ Each serializer field class constructor takes at least these arguments. Some Fi ...@@ -26,6 +20,8 @@ Each serializer field class constructor takes at least these arguments. Some Fi
### `read_only` ### `read_only`
Read-only fields are included in the API output, but should not be included in the input during create or update operations. Any 'read_only' fields that are incorrectly included in the serializer input will be ignored.
Set this to `True` to ensure that the field is used when serializing a representation, but is not used when creating or updating an instance during deserialization. Set this to `True` to ensure that the field is used when serializing a representation, but is not used when creating or updating an instance during deserialization.
Defaults to `False` Defaults to `False`
...@@ -189,6 +185,15 @@ A field that ensures the input is a valid UUID string. The `to_internal_value` m ...@@ -189,6 +185,15 @@ A field that ensures the input is a valid UUID string. The `to_internal_value` m
"de305d54-75b4-431b-adb2-eb6b9e546013" "de305d54-75b4-431b-adb2-eb6b9e546013"
**Signature:** `UUIDField(format='hex_verbose')`
- `format`: Determines the representation format of the uuid value
- `'hex_verbose'` - The cannoncical hex representation, including hyphens: `"5ce0e9a5-5ffa-654b-cee0-1238041fb31a"`
- `'hex'` - The compact hex representation of the UUID, not including hyphens: `"5ce0e9a55ffa654bcee01238041fb31a"`
- `'int'` - A 128 bit integer representation of the UUID: `"123456789012312313134124512351145145114"`
- `'urn'` - RFC 4122 URN representation of the UUID: `"urn:uuid:5ce0e9a5-5ffa-654b-cee0-1238041fb31a"`
Changing the `format` parameters only affects representation values. All formats are accepted by `to_internal_value`
## FilePathField ## FilePathField
A field whose choices are limited to the filenames in a certain directory on the filesystem A field whose choices are limited to the filenames in a certain directory on the filesystem
...@@ -203,6 +208,17 @@ Corresponds to `django.forms.fields.FilePathField`. ...@@ -203,6 +208,17 @@ Corresponds to `django.forms.fields.FilePathField`.
- `allow_files` - Specifies whether files in the specified location should be included. Default is `True`. Either this or `allow_folders` must be `True`. - `allow_files` - Specifies whether files in the specified location should be included. Default is `True`. Either this or `allow_folders` must be `True`.
- `allow_folders` - Specifies whether folders in the specified location should be included. Default is `False`. Either this or `allow_files` must be `True`. - `allow_folders` - Specifies whether folders in the specified location should be included. Default is `False`. Either this or `allow_files` must be `True`.
## IPAddressField
A field that ensures the input is a valid IPv4 or IPv6 string.
Corresponds to `django.forms.fields.IPAddressField` and `django.forms.fields.GenericIPAddressField`.
**Signature**: `IPAddressField(protocol='both', unpack_ipv4=False, **options)`
- `protocol` Limits valid inputs to the specified protocol. Accepted values are 'both' (default), 'IPv4' or 'IPv6'. Matching is case insensitive.
- `unpack_ipv4` Unpacks IPv4 mapped addresses like ::ffff:192.0.2.1. If this option is enabled that address would be unpacked to 192.0.2.1. Default is disabled. Can only be used when protocol is set to 'both'.
--- ---
# Numeric fields # Numeric fields
...@@ -322,6 +338,18 @@ Corresponds to `django.db.models.fields.TimeField` ...@@ -322,6 +338,18 @@ Corresponds to `django.db.models.fields.TimeField`
Format strings may either be [Python strftime formats][strftime] which explicitly specify the format, or the special string `'iso-8601'`, which indicates that [ISO 8601][iso8601] style times should be used. (eg `'12:34:56.000000'`) Format strings may either be [Python strftime formats][strftime] which explicitly specify the format, or the special string `'iso-8601'`, which indicates that [ISO 8601][iso8601] style times should be used. (eg `'12:34:56.000000'`)
## DurationField
A Duration representation.
Corresponds to `django.db.models.fields.DurationField`
The `validated_data` for these fields will contain a `datetime.timedelta` instance.
The representation is a string following this format `'[DD] [HH:[MM:]]ss[.uuuuuu]'`.
**Note:** This field is only available with Django versions >= 1.8.
**Signature:** `DurationField()`
--- ---
# Choice selection fields # Choice selection fields
...@@ -454,7 +482,7 @@ A field class that does not take a value based on user input, but instead takes ...@@ -454,7 +482,7 @@ A field class that does not take a value based on user input, but instead takes
For example, to include a field that always provides the current time as part of the serializer validated data, you would use the following: For example, to include a field that always provides the current time as part of the serializer validated data, you would use the following:
modified = serializer.HiddenField(default=timezone.now) modified = serializers.HiddenField(default=timezone.now)
The `HiddenField` class is usually only needed if you have some validation that needs to run based on some pre-provided field values, but you do not want to expose all of those fields to the end user. The `HiddenField` class is usually only needed if you have some validation that needs to run based on some pre-provided field values, but you do not want to expose all of those fields to the end user.
...@@ -501,7 +529,7 @@ If you want to create a custom field, you'll need to subclass `Field` and then o ...@@ -501,7 +529,7 @@ If you want to create a custom field, you'll need to subclass `Field` and then o
The `.to_representation()` method is called to convert the initial datatype into a primitive, serializable datatype. The `.to_representation()` method is called to convert the initial datatype into a primitive, serializable datatype.
The `to_internal_value()` method is called to restore a primitive datatype into its internal python representation. This method should raise a `serializer.ValidationError` if the data is invalid. The `to_internal_value()` method is called to restore a primitive datatype into its internal python representation. This method should raise a `serializers.ValidationError` if the data is invalid.
Note that the `WritableField` class that was present in version 2.x no longer exists. You should subclass `Field` and override `to_internal_value()` if the field supports data input. Note that the `WritableField` class that was present in version 2.x no longer exists. You should subclass `Field` and override `to_internal_value()` if the field supports data input.
......
...@@ -72,7 +72,7 @@ We can override `.get_queryset()` to deal with URLs such as `http://example.com/ ...@@ -72,7 +72,7 @@ We can override `.get_queryset()` to deal with URLs such as `http://example.com/
by filtering against a `username` query parameter in the URL. by filtering against a `username` query parameter in the URL.
""" """
queryset = Purchase.objects.all() queryset = Purchase.objects.all()
username = self.request.QUERY_PARAMS.get('username', None) username = self.request.query_params.get('username', None)
if username is not None: if username is not None:
queryset = queryset.filter(purchaser__username=username) queryset = queryset.filter(purchaser__username=username)
return queryset return queryset
...@@ -149,6 +149,7 @@ If all you need is simple equality-based filtering, you can set a `filter_fields ...@@ -149,6 +149,7 @@ If all you need is simple equality-based filtering, you can set a `filter_fields
class ProductList(generics.ListAPIView): class ProductList(generics.ListAPIView):
queryset = Product.objects.all() queryset = Product.objects.all()
serializer_class = ProductSerializer serializer_class = ProductSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('category', 'in_stock') filter_fields = ('category', 'in_stock')
This will automatically create a `FilterSet` class for the given fields, and will allow you to make requests such as: This will automatically create a `FilterSet` class for the given fields, and will allow you to make requests such as:
...@@ -174,6 +175,7 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha ...@@ -174,6 +175,7 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha
class ProductList(generics.ListAPIView): class ProductList(generics.ListAPIView):
queryset = Product.objects.all() queryset = Product.objects.all()
serializer_class = ProductSerializer serializer_class = ProductSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_class = ProductFilter filter_class = ProductFilter
...@@ -395,6 +397,10 @@ The following third party packages provide additional filter implementations. ...@@ -395,6 +397,10 @@ The following third party packages provide additional filter implementations.
The [django-rest-framework-filters package][django-rest-framework-filters] works together with the `DjangoFilterBackend` class, and allows you to easily create filters across relationships, or create multiple filter lookup types for a given field. The [django-rest-framework-filters package][django-rest-framework-filters] works together with the `DjangoFilterBackend` class, and allows you to easily create filters across relationships, or create multiple filter lookup types for a given field.
## Django REST framework full word search filter
The [djangorestframework-word-filter][django-rest-framework-word-search-filter] developed as alternative to `filters.SearchFilter` which will search full word in text, or exact match.
[cite]: https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-specific-objects-with-filters [cite]: https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-specific-objects-with-filters
[django-filter]: https://github.com/alex/django-filter [django-filter]: https://github.com/alex/django-filter
[django-filter-docs]: https://django-filter.readthedocs.org/en/latest/index.html [django-filter-docs]: https://django-filter.readthedocs.org/en/latest/index.html
...@@ -404,3 +410,4 @@ The [django-rest-framework-filters package][django-rest-framework-filters] works ...@@ -404,3 +410,4 @@ The [django-rest-framework-filters package][django-rest-framework-filters] works
[nullbooleanselect]: https://github.com/django/django/blob/master/django/forms/widgets.py [nullbooleanselect]: https://github.com/django/django/blob/master/django/forms/widgets.py
[search-django-admin]: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fields [search-django-admin]: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fields
[django-rest-framework-filters]: https://github.com/philipn/django-rest-framework-filters [django-rest-framework-filters]: https://github.com/philipn/django-rest-framework-filters
[django-rest-framework-word-search-filter]: https://github.com/trollknurr/django-rest-framework-word-search-filter
source: mixins.py source: mixins.py
generics.py generics.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Generic views # Generic views
> Django’s generic views... were developed as a shortcut for common usage patterns... They take certain common idioms and patterns found in view development and abstract them so that you can quickly write common views of data without having to repeat yourself. > Django’s generic views... were developed as a shortcut for common usage patterns... They take certain common idioms and patterns found in view development and abstract them so that you can quickly write common views of data without having to repeat yourself.
...@@ -57,7 +51,7 @@ For more complex cases you might also want to override various methods on the vi ...@@ -57,7 +51,7 @@ For more complex cases you might also want to override various methods on the vi
For very simple cases you might want to pass through any class attributes using the `.as_view()` method. For example, your URLconf might include something like the following entry: For very simple cases you might want to pass through any class attributes using the `.as_view()` method. For example, your URLconf might include something like the following entry:
url(r'^/users/', ListCreateAPIView.as_view(model=User), name='user-list') url(r'^/users/', ListCreateAPIView.as_view(queryset=User.objects.all(), serializer_class=UserSerializer), name='user-list')
--- ---
...@@ -84,10 +78,9 @@ The following attributes control the basic view behavior. ...@@ -84,10 +78,9 @@ The following attributes control the basic view behavior.
The following attributes are used to control pagination when used with list views. The following attributes are used to control pagination when used with list views.
* `paginate_by` - The size of pages to use with paginated data. If set to `None` then pagination is turned off. If unset this uses the same value as the `PAGINATE_BY` setting, which defaults to `None`. * `pagination_class` - The pagination class that should be used when paginating list results. Defaults to the same value as the `DEFAULT_PAGINATION_CLASS` setting, which is `'rest_framework.pagination.PageNumberPagination'`.
* `paginate_by_param` - The name of a query parameter, which can be used by the client to override the default page size to use for pagination. If unset this uses the same value as the `PAGINATE_BY_PARAM` setting, which defaults to `None`.
* `pagination_serializer_class` - The pagination serializer class to use when determining the style of paginated responses. Defaults to the same value as the `DEFAULT_PAGINATION_SERIALIZER_CLASS` setting. Note that usage of the `paginate_by`, `paginate_by_param` and `page_kwarg` attributes are now pending deprecation. The `pagination_serializer_class` attribute and `DEFAULT_PAGINATION_SERIALIZER_CLASS` setting have been removed completely. Pagination settings should instead be controlled by overriding a pagination class and setting any configuration attributes there. See the pagination documentation for more details.
* `page_kwarg` - The name of a URL kwarg or URL query parameter which can be used by the client to control which page is requested. Defaults to `'page'`.
**Filtering**: **Filtering**:
...@@ -131,21 +124,24 @@ For example: ...@@ -131,21 +124,24 @@ For example:
Note that if your API doesn't include any object level permissions, you may optionally exclude the `self.check_object_permissions`, and simply return the object from the `get_object_or_404` lookup. Note that if your API doesn't include any object level permissions, you may optionally exclude the `self.check_object_permissions`, and simply return the object from the `get_object_or_404` lookup.
#### `get_filter_backends(self)` #### `filter_queryset(self, queryset)`
Returns the classes that should be used to filter the queryset. Defaults to returning the `filter_backends` attribute. Given a queryset, filter it with whichever filter backends are in use, returning a new queryset.
May be overridden to provide more complex behavior with filters, such as using different (or even exlusive) lists of filter_backends depending on different criteria. For example:
For example: def filter_queryset(self, queryset):
filter_backends = (CategoryFilter,)
def get_filter_backends(self):
if "geo_route" in self.request.QUERY_PARAMS: if 'geo_route' in self.request.query_params:
return (GeoRouteFilter, CategoryFilter) filter_backends = (GeoRouteFilter, CategoryFilter)
elif "geo_point" in self.request.QUERY_PARAMS: elif 'geo_point' in self.request.query_params:
return (GeoPointFilter, CategoryFilter) filter_backends = (GeoPointFilter, CategoryFilter)
return (CategoryFilter,) for backend in list(filter_backends):
queryset = backend().filter_queryset(self.request, queryset, view=self)
return queryset
#### `get_serializer_class(self)` #### `get_serializer_class(self)`
...@@ -199,8 +195,8 @@ These override points are also particularly useful for adding behavior that occu ...@@ -199,8 +195,8 @@ These override points are also particularly useful for adding behavior that occu
You won't typically need to override the following methods, although you might need to call into them if you're writing custom views using `GenericAPIView`. You won't typically need to override the following methods, although you might need to call into them if you're writing custom views using `GenericAPIView`.
* `get_serializer_context(self)` - Returns a dictionary containing any extra context that should be supplied to the serializer. Defaults to including `'request'`, `'view'` and `'format'` keys. * `get_serializer_context(self)` - Returns a dictionary containing any extra context that should be supplied to the serializer. Defaults to including `'request'`, `'view'` and `'format'` keys.
* `get_serializer(self, instance=None, data=None, files=None, many=False, partial=False, allow_add_remove=False)` - Returns a serializer instance. * `get_serializer(self, instance=None, data=None, many=False, partial=False)` - Returns a serializer instance.
* `get_pagination_serializer(self, page)` - Returns a serializer instance to use with paginated data. * `get_paginated_response(self, data)` - Returns a paginated style `Response` object.
* `paginate_queryset(self, queryset)` - Paginate a queryset if required, either returning a page object, or `None` if pagination is not configured for this view. * `paginate_queryset(self, queryset)` - Paginate a queryset if required, either returning a page object, or `None` if pagination is not configured for this view.
* `filter_queryset(self, queryset)` - Given a queryset, filter it with whichever filter backends are in use, returning a new queryset. * `filter_queryset(self, queryset)` - Given a queryset, filter it with whichever filter backends are in use, returning a new queryset.
...@@ -398,6 +394,10 @@ The following third party packages provide additional generic view implementatio ...@@ -398,6 +394,10 @@ The following third party packages provide additional generic view implementatio
The [django-rest-framework-bulk package][django-rest-framework-bulk] implements generic view mixins as well as some common concrete generic views to allow to apply bulk operations via API requests. The [django-rest-framework-bulk package][django-rest-framework-bulk] implements generic view mixins as well as some common concrete generic views to allow to apply bulk operations via API requests.
## Django Rest Multiple Models
[Django Rest Multiple Models][django-rest-multiple-models] provides a generic view (and mixin) for sending multiple serialized models and/or querysets via a single API request.
[cite]: https://docs.djangoproject.com/en/dev/ref/class-based-views/#base-vs-generic-views [cite]: https://docs.djangoproject.com/en/dev/ref/class-based-views/#base-vs-generic-views
[GenericAPIView]: #genericapiview [GenericAPIView]: #genericapiview
...@@ -407,3 +407,6 @@ The [django-rest-framework-bulk package][django-rest-framework-bulk] implements ...@@ -407,3 +407,6 @@ The [django-rest-framework-bulk package][django-rest-framework-bulk] implements
[UpdateModelMixin]: #updatemodelmixin [UpdateModelMixin]: #updatemodelmixin
[DestroyModelMixin]: #destroymodelmixin [DestroyModelMixin]: #destroymodelmixin
[django-rest-framework-bulk]: https://github.com/miki725/django-rest-framework-bulk [django-rest-framework-bulk]: https://github.com/miki725/django-rest-framework-bulk
[django-rest-multiple-models]: https://github.com/Axiologue/DjangoRestMultipleModels
source: metadata.py source: metadata.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Metadata # Metadata
> [The `OPTIONS`] method allows a client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. > [The `OPTIONS`] method allows a client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.
...@@ -59,7 +53,7 @@ Or you can set the metadata class individually for a view: ...@@ -59,7 +53,7 @@ Or you can set the metadata class individually for a view:
class APIRoot(APIView): class APIRoot(APIView):
metadata_class = APIRootMetadata metadata_class = APIRootMetadata
def get(self, request, format=None): def get(self, request, format=None):
return Response({ return Response({
... ...
...@@ -104,6 +98,12 @@ The following class could be used to limit the information that is returned to ` ...@@ -104,6 +98,12 @@ The following class could be used to limit the information that is returned to `
'description': view.get_view_description() 'description': view.get_view_description()
} }
Then configure your settings to use this custom class:
REST_FRAMEWORK = {
'DEFAULT_METADATA_CLASS': 'myproject.apps.core.MinimalMetadata'
}
[cite]: http://tools.ietf.org/html/rfc7231#section-4.3.7 [cite]: http://tools.ietf.org/html/rfc7231#section-4.3.7
[no-options]: https://www.mnot.net/blog/2012/10/29/NO_OPTIONS [no-options]: https://www.mnot.net/blog/2012/10/29/NO_OPTIONS
[json-schema]: http://json-schema.org/ [json-schema]: http://json-schema.org/
...@@ -144,17 +144,16 @@ By default this will include the following keys: `view`, `request`, `args`, `kwa ...@@ -144,17 +144,16 @@ By default this will include the following keys: `view`, `request`, `args`, `kwa
The following is an example plaintext parser that will populate the `request.data` property with a string representing the body of the request. The following is an example plaintext parser that will populate the `request.data` property with a string representing the body of the request.
class PlainTextParser(BaseParser): class PlainTextParser(BaseParser):
"""
Plain text parser.
"""
media_type = 'text/plain'
def parse(self, stream, media_type=None, parser_context=None):
""" """
Simply return a string representing the body of the request. Plain text parser.
""" """
return stream.read() media_type = 'text/plain'
def parse(self, stream, media_type=None, parser_context=None):
"""
Simply return a string representing the body of the request.
"""
return stream.read()
--- ---
......
...@@ -150,7 +150,7 @@ Similar to `DjangoModelPermissions`, but also allows unauthenticated users to ha ...@@ -150,7 +150,7 @@ Similar to `DjangoModelPermissions`, but also allows unauthenticated users to ha
This permission class ties into Django's standard [object permissions framework][objectpermissions] that allows per-object permissions on models. In order to use this permission class, you'll also need to add a permission backend that supports object-level permissions, such as [django-guardian][guardian]. This permission class ties into Django's standard [object permissions framework][objectpermissions] that allows per-object permissions on models. In order to use this permission class, you'll also need to add a permission backend that supports object-level permissions, such as [django-guardian][guardian].
As with `DjangoModelPermissions`, this permission must only be applied to views that have a `.queryset` property. Authorization will only be granted if the user *is authenticated* and has the *relevant per-object permissions* and *relevant model permissions* assigned. As with `DjangoModelPermissions`, this permission must only be applied to views that have a `.queryset` property or `.get_queryset()` method. Authorization will only be granted if the user *is authenticated* and has the *relevant per-object permissions* and *relevant model permissions* assigned.
* `POST` requests require the user to have the `add` permission on the model instance. * `POST` requests require the user to have the `add` permission on the model instance.
* `PUT` and `PATCH` requests require the user to have the `change` permission on the model instance. * `PUT` and `PATCH` requests require the user to have the `change` permission on the model instance.
...@@ -190,6 +190,16 @@ If you need to test if a request is a read operation or a write operation, you s ...@@ -190,6 +190,16 @@ If you need to test if a request is a read operation or a write operation, you s
--- ---
Custom permissions will raise a `PermissionDenied` exception if the test fails. To change the error message associated with the exception, implement a `message` attribute directly on your custom permission. Otherwise the `default_detail` attribute from `PermissionDenied` will be used.
from rest_framework import permissions
class CustomerAccessPermission(permissions.BasePermission):
message = 'Adding customers not allowed.'
def has_permission(self, request, view):
...
## Examples ## Examples
The following is an example of a permission class that checks the incoming request's IP address against a blacklist, and denies the request if the IP has been blacklisted. The following is an example of a permission class that checks the incoming request's IP address against a blacklist, and denies the request if the IP has been blacklisted.
...@@ -233,10 +243,6 @@ Also note that the generic views will only check the object-level permissions fo ...@@ -233,10 +243,6 @@ Also note that the generic views will only check the object-level permissions fo
The following third party packages are also available. The following third party packages are also available.
## DRF Any Permissions
The [DRF Any Permissions][drf-any-permissions] packages provides a different permission behavior in contrast to REST framework. Instead of all specified permissions being required, only one of the given permissions has to be true in order to get access to the view.
## Composed Permissions ## Composed Permissions
The [Composed Permissions][composed-permissions] package provides a simple way to define complex and multi-depth (with logic operators) permission objects, using small and reusable components. The [Composed Permissions][composed-permissions] package provides a simple way to define complex and multi-depth (with logic operators) permission objects, using small and reusable components.
......
source: relations.py source: relations.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Serializer relations # Serializer relations
> Bad programmers worry about the code. > Bad programmers worry about the code.
...@@ -52,7 +46,7 @@ In order to explain the various types of relational fields, we'll use a couple o ...@@ -52,7 +46,7 @@ In order to explain the various types of relational fields, we'll use a couple o
class Meta: class Meta:
unique_together = ('album', 'order') unique_together = ('album', 'order')
order_by = 'order' ordering = ['order']
def __unicode__(self): def __unicode__(self):
return '%d: %s' % (self.order, self.title) return '%d: %s' % (self.order, self.title)
...@@ -122,6 +116,8 @@ By default this field is read-write, although you can change this behavior using ...@@ -122,6 +116,8 @@ By default this field is read-write, although you can change this behavior using
* `queryset` - The queryset used for model instance lookups when validating the field input. Relationships must either set a queryset explicitly, or set `read_only=True`. * `queryset` - The queryset used for model instance lookups when validating the field input. Relationships must either set a queryset explicitly, or set `read_only=True`.
* `many` - If applied to a to-many relationship, you should set this argument to `True`. * `many` - If applied to a to-many relationship, you should set this argument to `True`.
* `allow_null` - If set to `True`, the field will accept values of `None` or the empty string for nullable relationships. Defaults to `False`. * `allow_null` - If set to `True`, the field will accept values of `None` or the empty string for nullable relationships. Defaults to `False`.
* `pk_field` - Set to a field to control serialization/deserialization of the primary key's value. For example, `pk_field=UUIDField(format='hex')` would serialize a UUID primary key into its compact hex representation.
## HyperlinkedRelatedField ## HyperlinkedRelatedField
...@@ -260,17 +256,64 @@ For example, the following serializer: ...@@ -260,17 +256,64 @@ For example, the following serializer:
Would serialize to a nested representation like this: Would serialize to a nested representation like this:
>>> album = Album.objects.create(album_name="The Grey Album", artist='Danger Mouse')
>>> Track.objects.create(album=album, order=1, title='Public Service Announcement', duration=245)
<Track: Track object>
>>> Track.objects.create(album=album, order=2, title='What More Can I Say', duration=264)
<Track: Track object>
>>> Track.objects.create(album=album, order=3, title='Encore', duration=159)
<Track: Track object>
>>> serializer = AlbumSerializer(instance=album)
>>> serializer.data
{ {
'album_name': 'The Grey Album', 'album_name': 'The Grey Album',
'artist': 'Danger Mouse', 'artist': 'Danger Mouse',
'tracks': [ 'tracks': [
{'order': 1, 'title': 'Public Service Announcement'}, {'order': 1, 'title': 'Public Service Announcement', 'duration': 245},
{'order': 2, 'title': 'What More Can I Say'}, {'order': 2, 'title': 'What More Can I Say', 'duration': 264},
{'order': 3, 'title': 'Encore'}, {'order': 3, 'title': 'Encore', 'duration': 159},
... ...
], ],
} }
# Writable nested serializers
Be default nested serializers are read-only. If you want to to support write-operations to a nested serializer field you'll need to create either or both of the `create()` and/or `update()` methods, in order to explicitly specify how the child relationships should be saved.
class TrackSerializer(serializers.ModelSerializer):
class Meta:
model = Track
fields = ('order', 'title')
class AlbumSerializer(serializers.ModelSerializer):
tracks = TrackSerializer(many=True)
class Meta:
model = Album
fields = ('album_name', 'artist', 'tracks')
def create(self, validated_data):
tracks_data = validated_data.pop('tracks')
album = Album.objects.create(**validated_data)
for track_data in tracks_data:
Track.objects.create(album=album, **track_data)
return album
>>> data = {
'album_name': 'The Grey Album',
'artist': 'Danger Mouse',
'tracks': [
{'order': 1, 'title': 'Public Service Announcement', 'duration': 245},
{'order': 2, 'title': 'What More Can I Say', 'duration': 264},
{'order': 3, 'title': 'Encore', 'duration': 159},
],
}
>>> serializer = AlbumSerializer(data=data)
>>> serializer.is_valid()
True
>>> serializer.save()
<Album: Album object>
# Custom relational fields # Custom relational fields
To implement a custom relational field, you should override `RelatedField`, and implement the `.to_representation(self, value)` method. This method takes the target of the field as the `value` argument, and should return the representation that should be used to serialize the target. The `value` argument will typically be a model instance. To implement a custom relational field, you should override `RelatedField`, and implement the `.to_representation(self, value)` method. This method takes the target of the field as the `value` argument, and should return the representation that should be used to serialize the target. The `value` argument will typically be a model instance.
...@@ -279,7 +322,7 @@ If you want to implement a read-write relational field, you must also implement ...@@ -279,7 +322,7 @@ If you want to implement a read-write relational field, you must also implement
## Example ## Example
For, example, we could define a relational field, to serialize a track to a custom string representation, using its ordering, title, and duration. For example, we could define a relational field to serialize a track to a custom string representation, using its ordering, title, and duration.
import time import time
......
...@@ -110,7 +110,7 @@ An example of a view that uses `TemplateHTMLRenderer`: ...@@ -110,7 +110,7 @@ An example of a view that uses `TemplateHTMLRenderer`:
class UserDetail(generics.RetrieveAPIView): class UserDetail(generics.RetrieveAPIView):
""" """
A view that returns a templated HTML representations of a given user. A view that returns a templated HTML representation of a given user.
""" """
queryset = User.objects.all() queryset = User.objects.all()
renderer_classes = (TemplateHTMLRenderer,) renderer_classes = (TemplateHTMLRenderer,)
...@@ -135,7 +135,7 @@ See also: `StaticHTMLRenderer` ...@@ -135,7 +135,7 @@ See also: `StaticHTMLRenderer`
A simple renderer that simply returns pre-rendered HTML. Unlike other renderers, the data passed to the response object should be a string representing the content to be returned. A simple renderer that simply returns pre-rendered HTML. Unlike other renderers, the data passed to the response object should be a string representing the content to be returned.
An example of a view that uses `TemplateHTMLRenderer`: An example of a view that uses `StaticHTMLRenderer`:
@api_view(('GET',)) @api_view(('GET',))
@renderer_classes((StaticHTMLRenderer,)) @renderer_classes((StaticHTMLRenderer,))
...@@ -143,7 +143,7 @@ An example of a view that uses `TemplateHTMLRenderer`: ...@@ -143,7 +143,7 @@ An example of a view that uses `TemplateHTMLRenderer`:
data = '<html><body><h1>Hello, world</h1></body></html>' data = '<html><body><h1>Hello, world</h1></body></html>'
return Response(data) return Response(data)
You can use `TemplateHTMLRenderer` either to return regular HTML pages using REST framework, or to return both HTML and API responses from a single endpoint. You can use `StaticHTMLRenderer` either to return regular HTML pages using REST framework, or to return both HTML and API responses from a single endpoint.
**.media_type**: `text/html` **.media_type**: `text/html`
...@@ -157,7 +157,7 @@ See also: `TemplateHTMLRenderer` ...@@ -157,7 +157,7 @@ See also: `TemplateHTMLRenderer`
Renders data returned by a serializer into an HTML form. The output of this renderer does not include the enclosing `<form>` tags or an submit actions, as you'll probably need those to include the desired method and URL. Also note that the `HTMLFormRenderer` does not yet support including field error messages. Renders data returned by a serializer into an HTML form. The output of this renderer does not include the enclosing `<form>` tags or an submit actions, as you'll probably need those to include the desired method and URL. Also note that the `HTMLFormRenderer` does not yet support including field error messages.
Note that the template used by the `HTMLFormRenderer` class, and the context submitted to it **may be subject to change**. If you need to use this renderer class it is advised that you either make a local copy of the class and templates, or follow the release note on REST framework upgrades closely. **Note**: The `HTMLFormRenderer` class is intended for internal use with the browsable API. It should not be considered a fully documented or stable API. The template used by the `HTMLFormRenderer` class, and the context submitted to it **may be subject to change**. If you need to use this renderer class it is advised that you either make a local copy of the class and templates, or follow the release note on REST framework upgrades closely.
**.media_type**: `text/html` **.media_type**: `text/html`
...@@ -181,7 +181,7 @@ Renders data into HTML for the Browsable API. This renderer will determine whic ...@@ -181,7 +181,7 @@ Renders data into HTML for the Browsable API. This renderer will determine whic
#### Customizing BrowsableAPIRenderer #### Customizing BrowsableAPIRenderer
By default the response content will be rendered with the highest priority renderer apart from `BrowseableAPIRenderer`. If you need to customize this behavior, for example to use HTML as the default return format, but use JSON in the browsable API, you can do so by overriding the `get_default_renderer()` method. For example: By default the response content will be rendered with the highest priority renderer apart from `BrowsableAPIRenderer`. If you need to customize this behavior, for example to use HTML as the default return format, but use JSON in the browsable API, you can do so by overriding the `get_default_renderer()` method. For example:
class CustomBrowsableAPIRenderer(BrowsableAPIRenderer): class CustomBrowsableAPIRenderer(BrowsableAPIRenderer):
def get_default_renderer(self, view): def get_default_renderer(self, view):
...@@ -406,7 +406,7 @@ Modify your REST framework settings. ...@@ -406,7 +406,7 @@ Modify your REST framework settings.
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': ( 'DEFAULT_RENDERER_CLASSES': (
'rest_framework_yaml.renderers.JSONPRenderer', 'rest_framework_jsonp.renderers.JSONPRenderer',
), ),
} }
......
source: request.py source: request.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Requests # Requests
> If you're doing REST-based web service stuff ... you should ignore request.POST. > If you're doing REST-based web service stuff ... you should ignore request.POST.
......
...@@ -290,14 +290,14 @@ The following third party packages are also available. ...@@ -290,14 +290,14 @@ The following third party packages are also available.
The [drf-nested-routers package][drf-nested-routers] provides routers and relationship fields for working with nested resources. The [drf-nested-routers package][drf-nested-routers] provides routers and relationship fields for working with nested resources.
## wq.db ## ModelRouter (wq.db.rest)
The [wq.db package][wq.db] provides an advanced [Router][wq.db-router] class (and singleton instance) that extends `DefaultRouter` with a `register_model()` API. Much like Django's `admin.site.register`, the only required argument to `app.router.register_model` is a model class. Reasonable defaults for a url prefix and viewset will be inferred from the model and global configuration. The [wq.db package][wq.db] provides an advanced [ModelRouter][wq.db-router] class (and singleton instance) that extends `DefaultRouter` with a `register_model()` API. Much like Django's `admin.site.register`, the only required argument to `rest.router.register_model` is a model class. Reasonable defaults for a url prefix, serializer, and viewset will be inferred from the model and global configuration.
from wq.db.rest import app from wq.db import rest
from myapp.models import MyModel from myapp.models import MyModel
app.router.register_model(MyModel) rest.router.register_model(MyModel)
## DRF-extensions ## DRF-extensions
...@@ -307,7 +307,7 @@ The [`DRF-extensions` package][drf-extensions] provides [routers][drf-extensions ...@@ -307,7 +307,7 @@ The [`DRF-extensions` package][drf-extensions] provides [routers][drf-extensions
[route-decorators]: viewsets.md#marking-extra-actions-for-routing [route-decorators]: viewsets.md#marking-extra-actions-for-routing
[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers [drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
[wq.db]: http://wq.io/wq.db [wq.db]: http://wq.io/wq.db
[wq.db-router]: http://wq.io/docs/app.py [wq.db-router]: http://wq.io/docs/router
[drf-extensions]: http://chibisov.github.io/drf-extensions/docs/ [drf-extensions]: http://chibisov.github.io/drf-extensions/docs/
[drf-extensions-routers]: http://chibisov.github.io/drf-extensions/docs/#routers [drf-extensions-routers]: http://chibisov.github.io/drf-extensions/docs/#routers
[drf-extensions-nested-viewsets]: http://chibisov.github.io/drf-extensions/docs/#nested-routes [drf-extensions-nested-viewsets]: http://chibisov.github.io/drf-extensions/docs/#nested-routes
......
source: serializers.py source: serializers.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Serializers # Serializers
> Expanding the usefulness of the serializers is something that we would > Expanding the usefulness of the serializers is something that we would
...@@ -23,7 +17,7 @@ The serializers in REST framework work very similarly to Django's `Form` and `Mo ...@@ -23,7 +17,7 @@ The serializers in REST framework work very similarly to Django's `Form` and `Mo
Let's start by creating a simple object we can use for example purposes: Let's start by creating a simple object we can use for example purposes:
from datetime import datetime from datetime import datetime
class Comment(object): class Comment(object):
def __init__(self, email, content, created=None): def __init__(self, email, content, created=None):
self.email = email self.email = email
...@@ -350,7 +344,7 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas ...@@ -350,7 +344,7 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas
return instance return instance
Because the behavior of nested creates and updates can be ambiguous, and may require complex dependancies between related models, REST framework 3 requires you to always write these methods explicitly. The default `ModelSerializer` `.create()` and `.update()` methods do not include support for writable nested representations. Because the behavior of nested creates and updates can be ambiguous, and may require complex dependencies between related models, REST framework 3 requires you to always write these methods explicitly. The default `ModelSerializer` `.create()` and `.update()` methods do not include support for writable nested representations.
It is possible that a third party package, providing automatic support some kinds of automatic writable nested representations may be released alongside the 3.1 release. It is possible that a third party package, providing automatic support some kinds of automatic writable nested representations may be released alongside the 3.1 release.
...@@ -484,7 +478,7 @@ The default `ModelSerializer` uses primary keys for relationships, but you can a ...@@ -484,7 +478,7 @@ The default `ModelSerializer` uses primary keys for relationships, but you can a
The `depth` option should be set to an integer value that indicates the depth of relationships that should be traversed before reverting to a flat representation. The `depth` option should be set to an integer value that indicates the depth of relationships that should be traversed before reverting to a flat representation.
If you want to customize the way the serialization is done (e.g. using `allow_add_remove`) you'll need to define the field yourself. If you want to customize the way the serialization is done you'll need to define the field yourself.
## Specifying fields explicitly ## Specifying fields explicitly
...@@ -818,7 +812,7 @@ There are four methods that can be overridden, depending on what functionality y ...@@ -818,7 +812,7 @@ There are four methods that can be overridden, depending on what functionality y
* `.to_representation()` - Override this to support serialization, for read operations. * `.to_representation()` - Override this to support serialization, for read operations.
* `.to_internal_value()` - Override this to support deserialization, for write operations. * `.to_internal_value()` - Override this to support deserialization, for write operations.
* `.create()` and `.update()` - Overide either or both of these to support saving instances. * `.create()` and `.update()` - Override either or both of these to support saving instances.
Because this class provides the same interface as the `Serializer` class, you can use it with the existing generic class based views exactly as you would for a regular `Serializer` or `ModelSerializer`. Because this class provides the same interface as the `Serializer` class, you can use it with the existing generic class based views exactly as you would for a regular `Serializer` or `ModelSerializer`.
......
...@@ -273,6 +273,8 @@ Default: `'accept'` ...@@ -273,6 +273,8 @@ Default: `'accept'`
The name of a URL parameter that may be used to override the default `Accept` header based content negotiation. The name of a URL parameter that may be used to override the default `Accept` header based content negotiation.
If the value of this setting is `None` then URL format overloading will be disabled.
Default: `'format'` Default: `'format'`
--- ---
......
...@@ -65,7 +65,7 @@ When testing views directly using a request factory, it's often convenient to be ...@@ -65,7 +65,7 @@ When testing views directly using a request factory, it's often convenient to be
To forcibly authenticate a request, use the `force_authenticate()` method. To forcibly authenticate a request, use the `force_authenticate()` method.
from rest_framework.tests import force_authenticate from rest_framework.test import force_authenticate
factory = APIRequestFactory() factory = APIRequestFactory()
user = User.objects.get(username='olivia') user = User.objects.get(username='olivia')
......
source: validators.py source: validators.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Validators # Validators
> Validators can be useful for re-using validation logic between different types of fields. > Validators can be useful for re-using validation logic between different types of fields.
...@@ -33,7 +27,7 @@ When you're using `ModelSerializer` all of this is handled automatically for you ...@@ -33,7 +27,7 @@ When you're using `ModelSerializer` all of this is handled automatically for you
As an example of how REST framework uses explicit validation, we'll take a simple model class that has a field with a uniqueness constraint. As an example of how REST framework uses explicit validation, we'll take a simple model class that has a field with a uniqueness constraint.
class CustomerReportRecord(models.Model): class CustomerReportRecord(models.Model):
time_raised = models.DateTimeField(default=timezone.now, editable=False) time_raised = models.DateTimeField(default=timezone.now, editable=False)
reference = models.CharField(unique=True, max_length=20) reference = models.CharField(unique=True, max_length=20)
description = models.TextField() description = models.TextField()
...@@ -43,7 +37,7 @@ Here's a basic `ModelSerializer` that we can use for creating or updating instan ...@@ -43,7 +37,7 @@ Here's a basic `ModelSerializer` that we can use for creating or updating instan
class Meta: class Meta:
model = CustomerReportRecord model = CustomerReportRecord
If we open up the Django shell using `manage.py shell` we can now If we open up the Django shell using `manage.py shell` we can now
>>> from project.example.serializers import CustomerReportSerializer >>> from project.example.serializers import CustomerReportSerializer
>>> serializer = CustomerReportSerializer() >>> serializer = CustomerReportSerializer()
...@@ -178,7 +172,7 @@ REST framework includes a couple of defaults that may be useful in this context. ...@@ -178,7 +172,7 @@ REST framework includes a couple of defaults that may be useful in this context.
A default class that can be used to represent the current user. In order to use this, the 'request' must have been provided as part of the context dictionary when instantiating the serializer. A default class that can be used to represent the current user. In order to use this, the 'request' must have been provided as part of the context dictionary when instantiating the serializer.
owner = serializers.HiddenField( owner = serializers.HiddenField(
default=CurrentUserDefault() default=serializers.CurrentUserDefault()
) )
#### CreateOnlyDefault #### CreateOnlyDefault
...@@ -204,18 +198,18 @@ A validator may be any callable that raises a `serializers.ValidationError` on f ...@@ -204,18 +198,18 @@ A validator may be any callable that raises a `serializers.ValidationError` on f
def even_number(value): def even_number(value):
if value % 2 != 0: if value % 2 != 0:
raise serializers.ValidationError('This field must be an even number.') raise serializers.ValidationError('This field must be an even number.')
## Class based ## Class based
To write a class based validator, use the `__call__` method. Class based validators are useful as they allow you to parameterize and reuse behavior. To write a class based validator, use the `__call__` method. Class based validators are useful as they allow you to parameterize and reuse behavior.
class MultipleOf: class MultipleOf(object):
def __init__(self, base): def __init__(self, base):
self.base = base self.base = base
def __call__(self, value): def __call__(self, value):
if value % self.base != 0 if value % self.base != 0:
message = 'This field must be a multiple of %d.' % self.base message = 'This field must be a multiple of %d.' % self.base
raise serializers.ValidationError(message) raise serializers.ValidationError(message)
......
...@@ -3,7 +3,7 @@ source: versioning.py ...@@ -3,7 +3,7 @@ source: versioning.py
# Versioning # Versioning
> Versioning an interface is just a "polite" way to kill deployed clients. > Versioning an interface is just a "polite" way to kill deployed clients.
> >
> &mdash; [Roy Fielding][cite]. > &mdash; [Roy Fielding][cite].
API versioning allows you to alter behavior between different clients. REST framework provides for a number of different versioning schemes. API versioning allows you to alter behavior between different clients. REST framework provides for a number of different versioning schemes.
...@@ -31,6 +31,8 @@ How you vary the API behavior is up to you, but one example you might typically ...@@ -31,6 +31,8 @@ How you vary the API behavior is up to you, but one example you might typically
The `reverse` function included by REST framework ties in with the versioning scheme. You need to make sure to include the current `request` as a keyword argument, like so. The `reverse` function included by REST framework ties in with the versioning scheme. You need to make sure to include the current `request` as a keyword argument, like so.
from rest_framework.reverse import reverse
reverse('bookings-list', request=request) reverse('bookings-list', request=request)
The above function will apply any URL transformations appropriate to the request version. For example: The above function will apply any URL transformations appropriate to the request version. For example:
...@@ -69,9 +71,22 @@ You can also set the versioning scheme on an individual view. Typically you won' ...@@ -69,9 +71,22 @@ You can also set the versioning scheme on an individual view. Typically you won'
The following settings keys are also used to control versioning: The following settings keys are also used to control versioning:
* `DEFAULT_VERSION`. The value that should be used for `request.version` when no versioning information is present. Defaults to `None`. * `DEFAULT_VERSION`. The value that should be used for `request.version` when no versioning information is present. Defaults to `None`.
* `ALLOWED_VERSIONS`. If set, this value will restrict the set of versions that may be returned by the versioning scheme, and will raise an error if the provided version if not in this set. Defaults to `None`. * `ALLOWED_VERSIONS`. If set, this value will restrict the set of versions that may be returned by the versioning scheme, and will raise an error if the provided version if not in this set. Note that the value used for the `DEFAULT_VERSION` setting is always considered to be part of the `ALLOWED_VERSIONS` set. Defaults to `None`.
* `VERSION_PARAMETER`. The string that should used for any versioning parameters, such as in the media type or URL query parameters. Defaults to `'version'`. * `VERSION_PARAMETER`. The string that should used for any versioning parameters, such as in the media type or URL query parameters. Defaults to `'version'`.
You can also set your versioning class plus those three values on a per-view or a per-viewset basis by defining your own versioning scheme and using the `default_version`, `allowed_versions` and `version_param` class variables. For example, if you want to use `URLPathVersioning`:
from rest_framework.versioning import URLPathVersioning
from rest_framework.views import APIView
class ExampleVersioning(URLPathVersioning):
default_version = ...
allowed_versions = ...
version_param = ...
class ExampleView(APIVIew):
versioning_class = ExampleVersioning
--- ---
# API Reference # API Reference
...@@ -103,7 +118,7 @@ Your client requests would now look like this: ...@@ -103,7 +118,7 @@ Your client requests would now look like this:
Host: example.com Host: example.com
Accept: application/vnd.megacorp.bookings+json; version=1.0 Accept: application/vnd.megacorp.bookings+json; version=1.0
## URLParameterVersioning ## URLPathVersioning
This scheme requires the client to specify the version as part of the URL path. This scheme requires the client to specify the version as part of the URL path.
...@@ -115,12 +130,12 @@ Your URL conf must include a pattern that matches the version with a `'version'` ...@@ -115,12 +130,12 @@ Your URL conf must include a pattern that matches the version with a `'version'`
urlpatterns = [ urlpatterns = [
url( url(
r'^(?P<version>{v1,v2})/bookings/$', r'^(?P<version>[v1|v2]+)/bookings/$',
bookings_list, bookings_list,
name='bookings-list' name='bookings-list'
), ),
url( url(
r'^(?P<version>{v1,v2})/bookings/(?P<pk>[0-9]+)/$', r'^(?P<version>[v1|v2]+)/bookings/(?P<pk>[0-9]+)/$',
bookings_detail, bookings_detail,
name='bookings-detail' name='bookings-detail'
) )
......
...@@ -27,7 +27,7 @@ Let's define a simple viewset that can be used to list or retrieve all the users ...@@ -27,7 +27,7 @@ Let's define a simple viewset that can be used to list or retrieve all the users
class UserViewSet(viewsets.ViewSet): class UserViewSet(viewsets.ViewSet):
""" """
A simple ViewSet that for listing or retrieving users. A simple ViewSet for listing or retrieving users.
""" """
def list(self, request): def list(self, request):
queryset = User.objects.all() queryset = User.objects.all()
...@@ -136,8 +136,13 @@ For example: ...@@ -136,8 +136,13 @@ For example:
@list_route() @list_route()
def recent_users(self, request): def recent_users(self, request):
recent_users = User.objects.all().order('-last_login') recent_users = User.objects.all().order('-last_login')
page = self.paginate_queryset(recent_users) page = self.paginate_queryset(recent_users)
serializer = self.get_pagination_serializer(page) if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
serializer = self.get_serializer(recent_users, many=True)
return Response(serializer.data) return Response(serializer.data)
The decorators can additionally take extra arguments that will be set for the routed view only. For example... The decorators can additionally take extra arguments that will be set for the routed view only. For example...
......
<p class="badges" height=20px> <p class="badges" height=20px>
<iframe src="http://ghbtns.com/github-btn.html?user=tomchristie&amp;repo=django-rest-framework&amp;type=watch&amp;count=true" class="github-star-button" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe> <iframe src="http://ghbtns.com/github-btn.html?user=tomchristie&amp;repo=django-rest-framework&amp;type=watch&amp;count=true" class="github-star-button" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="django-rest-framework.org" data-text="Checking out the totally awesome Django REST framework! http://www.django-rest-framework.org" data-count="none"></a> <a href="http://travis-ci.org/tomchristie/django-rest-framework?branch=master">
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <img src="https://secure.travis-ci.org/tomchristie/django-rest-framework.svg?branch=master" class="status-badge">
</a>
<img src="https://secure.travis-ci.org/tomchristie/django-rest-framework.svg?branch=master" class="travis-build-image"> <a href="https://pypi.python.org/pypi/djangorestframework">
<img src="https://img.shields.io/pypi/v/djangorestframework.svg" class="status-badge">
</a>
</p> </p>
--- ---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available. **Note**: This is the documentation for the **version 3.1** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
For more details see the [3.0 release notes][3.0-announcement]. For more details see the [3.1 release notes][3.1-announcement].
--- ---
...@@ -50,7 +53,7 @@ Some reasons you might want to use REST framework: ...@@ -50,7 +53,7 @@ Some reasons you might want to use REST framework:
REST framework requires the following: REST framework requires the following:
* Python (2.6.5+, 2.7, 3.2, 3.3, 3.4) * Python (2.6.5+, 2.7, 3.2, 3.3, 3.4)
* Django (1.4.11+, 1.5.6+, 1.6.3+, 1.7, 1.8-beta) * Django (1.4.11+, 1.5.6+, 1.6.3+, 1.7+, 1.8)
The following packages are optional: The following packages are optional:
...@@ -248,8 +251,6 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ...@@ -248,8 +251,6 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[travis]: http://travis-ci.org/tomchristie/django-rest-framework?branch=master
[travis-build-image]: https://secure.travis-ci.org/tomchristie/django-rest-framework.png?branch=master
[mozilla]: http://www.mozilla.org/en-US/about/ [mozilla]: http://www.mozilla.org/en-US/about/
[eventbrite]: https://www.eventbrite.co.uk/about/ [eventbrite]: https://www.eventbrite.co.uk/about/
[markdown]: http://pypi.python.org/pypi/Markdown/ [markdown]: http://pypi.python.org/pypi/Markdown/
......
...@@ -940,7 +940,7 @@ The default JSON renderer will return float objects for un-coerced `Decimal` ins ...@@ -940,7 +940,7 @@ The default JSON renderer will return float objects for un-coerced `Decimal` ins
* The serializer `ChoiceField` does not currently display nested choices, as was the case in 2.4. This will be address as part of 3.1. * The serializer `ChoiceField` does not currently display nested choices, as was the case in 2.4. This will be address as part of 3.1.
* Due to the new templated form rendering, the 'widget' option is no longer valid. This means there's no easy way of using third party "autocomplete" widgets for rendering select inputs that contain a large number of choices. You'll either need to use a regular select or a plain text input. We may consider addressing this in 3.1 or 3.2 if there's sufficient demand. * Due to the new templated form rendering, the 'widget' option is no longer valid. This means there's no easy way of using third party "autocomplete" widgets for rendering select inputs that contain a large number of choices. You'll either need to use a regular select or a plain text input. We may consider addressing this in 3.1 or 3.2 if there's sufficient demand.
* Some of the default validation error messages were rewritten and might no longer be pre-translated. You can still [create language files with Django][django-localization] if you wish to localize them. * Some of the default validation error messages were rewritten and might no longer be pre-translated. You can still [create language files with Django][django-localization] if you wish to localize them.
* `APIException` subclasses could previously take could previously take any arbitrary type in the `detail` argument. These exceptions now use translatable text strings, and as a result call `force_text` on the `detail` argument, which *must be a string*. If you need complex arguments to an `APIException` class, you should subclass it and override the `__init__()` method. Typically you'll instead want to use a custom exception handler to provide for non-standard error responses. * `APIException` subclasses could previously take any arbitrary type in the `detail` argument. These exceptions now use translatable text strings, and as a result call `force_text` on the `detail` argument, which *must be a string*. If you need complex arguments to an `APIException` class, you should subclass it and override the `__init__()` method. Typically you'll instead want to use a custom exception handler to provide for non-standard error responses.
--- ---
......
...@@ -17,6 +17,15 @@ Some highlights include: ...@@ -17,6 +17,15 @@ Some highlights include:
The pagination API has been improved, making it both easier to use, and more powerful. The pagination API has been improved, making it both easier to use, and more powerful.
A guide to the headline features follows. For full details, see [the pagination documentation][pagination].
Note that as a result of this work a number of settings keys and generic view attributes are now moved to pending deprecation. Controlling pagination styles is now largely handled by overriding a pagination class and modifying its configuration attributes.
* The `PAGINATE_BY` settings key will continue to work but is now pending deprecation. The more obviously named `PAGE_SIZE` settings key should now be used instead.
* The `PAGINATE_BY_PARAM`, `MAX_PAGINATE_BY` settings keys will continue to work but are now pending deprecation, in favor of setting configuration attributes on the configured pagination class.
* The `paginate_by`, `page_query_param`, `paginate_by_param` and `max_paginate_by` generic view attributes will continue to work but are now pending deprecation, in favor of setting configuration attributes on the configured pagination class.
* The `pagination_serializer_class` view attribute and `DEFAULT_PAGINATION_SERIALIZER_CLASS` settings key **are no longer valid**. The pagination API does not use serializers to determine the output format, and you'll need to instead override the `get_paginated_response` method on a pagination class in order to specify how the output format is controlled.
#### New pagination schemes. #### New pagination schemes.
Until now, there has only been a single built-in pagination style in REST framework. We now have page, limit/offset and cursor based schemes included by default. Until now, there has only been a single built-in pagination style in REST framework. We now have page, limit/offset and cursor based schemes included by default.
...@@ -43,7 +52,7 @@ For more information, see the [custom pagination styles](../api-guide/pagination ...@@ -43,7 +52,7 @@ For more information, see the [custom pagination styles](../api-guide/pagination
## Versioning ## Versioning
We've made it easier to build versioned APIs. Built-in schemes for versioning include both URL based and Accept header based variations. We've made it [easier to build versioned APIs][versioning]. Built-in schemes for versioning include both URL based and Accept header based variations.
When using a URL based scheme, hyperlinked serializers will resolve relationships to the same API version as used on the incoming request. When using a URL based scheme, hyperlinked serializers will resolve relationships to the same API version as used on the incoming request.
...@@ -71,7 +80,7 @@ The output representation would match the version used on the incoming request. ...@@ -71,7 +80,7 @@ The output representation would match the version used on the incoming request.
## Internationalization ## Internationalization
REST framework now includes a built-in set of translations, and supports internationalized error responses. This allows you to either change the default language, or to allow clients to specify the language via the `Accept-Language` header. REST framework now includes a built-in set of translations, and [supports internationalized error responses][internationalization]. This allows you to either change the default language, or to allow clients to specify the language via the `Accept-Language` header.
You can change the default language by using the standard Django `LANGUAGE_CODE` setting: You can change the default language by using the standard Django `LANGUAGE_CODE` setting:
...@@ -136,7 +145,7 @@ If you're building a new 1.8 project, then you should probably consider using `U ...@@ -136,7 +145,7 @@ If you're building a new 1.8 project, then you should probably consider using `U
The serializer redesign in 3.0 did not include any public API for modifying how ModelSerializer classes automatically generate a set of fields from a given mode class. We've now re-introduced an API for this, allowing you to create new ModelSerializer base classes that behave differently, such as using a different default style for relationships. The serializer redesign in 3.0 did not include any public API for modifying how ModelSerializer classes automatically generate a set of fields from a given mode class. We've now re-introduced an API for this, allowing you to create new ModelSerializer base classes that behave differently, such as using a different default style for relationships.
For more information, see the documentation on [customizing field mappings](../api-guide/serializers/#customizing-field-mappings) for ModelSerializer classes. For more information, see the documentation on [customizing field mappings][customizing-field-mappings] for ModelSerializer classes.
--- ---
...@@ -194,3 +203,7 @@ The next focus will be on HTML renderings of API output and will include: ...@@ -194,3 +203,7 @@ The next focus will be on HTML renderings of API output and will include:
This will either be made as a single 3.2 release, or split across two separate releases, with the HTML forms and filter controls coming in 3.2, and the admin-style interface coming in a 3.3 release. This will either be made as a single 3.2 release, or split across two separate releases, with the HTML forms and filter controls coming in 3.2, and the admin-style interface coming in a 3.3 release.
[custom-exception-handler]: ../api-guide/exceptions.md#custom-exception-handling [custom-exception-handler]: ../api-guide/exceptions.md#custom-exception-handling
[pagination]: ../api-guide/pagination.md
[versioning]: ../api-guide/versioning.md
[internationalization]: internationalization.md
[customizing-field-mappings]: ../api-guide/serializers.md#customizing-field-mappings
...@@ -35,7 +35,7 @@ To replace the default theme, add a `bootstrap_theme` block to your `api.html` a ...@@ -35,7 +35,7 @@ To replace the default theme, add a `bootstrap_theme` block to your `api.html` a
<link rel="stylesheet" href="/path/to/my/bootstrap.css" type="text/css"> <link rel="stylesheet" href="/path/to/my/bootstrap.css" type="text/css">
{% endblock %} {% endblock %}
A suitable replacement theme can be generated using Bootstrap's [Customize Tool][bcustomize]. There are also pre-made themes available at [Bootswatch][bswatch]. To use any of the Bootswatch themes, simply download the theme's `bootstrap.min.css` file, add it to your project, and replace the default one as described above. Suitable pre-made replacement themes are available at [Bootswatch][bswatch]. To use any of the Bootswatch themes, simply download the theme's `bootstrap.min.css` file, add it to your project, and replace the default one as described above.
You can also change the navbar variant, which by default is `navbar-inverse`, using the `bootstrap_navbar_variant` block. The empty `{% block bootstrap_navbar_variant %}{% endblock %}` will use the original Bootstrap navbar style. You can also change the navbar variant, which by default is `navbar-inverse`, using the `bootstrap_navbar_variant` block. The empty `{% block bootstrap_navbar_variant %}{% endblock %}` will use the original Bootstrap navbar style.
......
...@@ -97,9 +97,15 @@ The following template should be used for the description of the issue, and serv ...@@ -97,9 +97,15 @@ The following template should be used for the description of the issue, and serv
Release manager is @***. Release manager is @***.
Pull request is #***. Pull request is #***.
During development cycle:
- [ ] Upload the new content to be translated to [transifex](http://www.django-rest-framework.org/topics/project-management/#translations).
Checklist: Checklist:
- [ ] Create pull request for [release notes](https://github.com/tomchristie/django-rest-framework/blob/master/docs/topics/release-notes.md) based on the [*.*.* milestone](https://github.com/tomchristie/django-rest-framework/milestones/***). - [ ] Create pull request for [release notes](https://github.com/tomchristie/django-rest-framework/blob/master/docs/topics/release-notes.md) based on the [*.*.* milestone](https://github.com/tomchristie/django-rest-framework/milestones/***).
- [ ] Update the translations from [transifex](http://www.django-rest-framework.org/topics/project-management/#translations).
- [ ] Ensure the pull request increments the version to `*.*.*` in [`restframework/__init__.py`](https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/__init__.py). - [ ] Ensure the pull request increments the version to `*.*.*` in [`restframework/__init__.py`](https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/__init__.py).
- [ ] Confirm with @tomchristie that release is finalized and ready to go. - [ ] Confirm with @tomchristie that release is finalized and ready to go.
- [ ] Ensure that release date is included in pull request. - [ ] Ensure that release date is included in pull request.
......
...@@ -32,7 +32,7 @@ REST framework also includes [serialization] and [parser]/[renderer] components ...@@ -32,7 +32,7 @@ REST framework also includes [serialization] and [parser]/[renderer] components
## What REST framework doesn't provide. ## What REST framework doesn't provide.
What REST framework doesn't do is give you is machine readable hypermedia formats such as [HAL][hal], [Collection+JSON][collection], [JSON API][json-api] or HTML [microformats] by default, or the ability to auto-magically create fully HATEOAS style APIs that include hypermedia-based form descriptions and semantically labelled hyperlinks. Doing so would involve making opinionated choices about API design that should really remain outside of the framework's scope. What REST framework doesn't do is give you machine readable hypermedia formats such as [HAL][hal], [Collection+JSON][collection], [JSON API][json-api] or HTML [microformats] by default, or the ability to auto-magically create fully HATEOAS style APIs that include hypermedia-based form descriptions and semantically labelled hyperlinks. Doing so would involve making opinionated choices about API design that should really remain outside of the framework's scope.
[cite]: http://vimeo.com/channels/restfest/page:2 [cite]: http://vimeo.com/channels/restfest/page:2
[dissertation]: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm [dissertation]: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
......
...@@ -206,10 +206,12 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque ...@@ -206,10 +206,12 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
* [drf-compound-fields][drf-compound-fields] - Provides "compound" serializer fields, such as lists of simple values. * [drf-compound-fields][drf-compound-fields] - Provides "compound" serializer fields, such as lists of simple values.
* [django-extra-fields][django-extra-fields] - Provides extra serializer fields. * [django-extra-fields][django-extra-fields] - Provides extra serializer fields.
* [django-versatileimagefield][django-versatileimagefield] - Provides a drop-in replacement for Django's stock `ImageField` that makes it easy to serve images in multiple sizes/renditions from a single field. For DRF-specific implementation docs, [click here][django-versatileimagefield-drf-docs].
### Views ### Views
* [djangorestframework-bulk][djangorestframework-bulk] - Implements generic view mixins as well as some common concrete generic views to allow to apply bulk operations via API requests. * [djangorestframework-bulk][djangorestframework-bulk] - Implements generic view mixins as well as some common concrete generic views to allow to apply bulk operations via API requests.
* [django-rest-multiple-models][django-rest-multiple-models] - Provides a generic view (and mixin) for sending multiple serialized models and/or querysets via a single API request.
### Routers ### Routers
...@@ -236,9 +238,12 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque ...@@ -236,9 +238,12 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
* [djangorestrelationalhyperlink][djangorestrelationalhyperlink] - A hyperlinked serialiser that can can be used to alter relationships via hyperlinks, but otherwise like a hyperlink model serializer. * [djangorestrelationalhyperlink][djangorestrelationalhyperlink] - A hyperlinked serialiser that can can be used to alter relationships via hyperlinks, but otherwise like a hyperlink model serializer.
* [django-rest-swagger][django-rest-swagger] - An API documentation generator for Swagger UI. * [django-rest-swagger][django-rest-swagger] - An API documentation generator for Swagger UI.
* [django-rest-framework-proxy][django-rest-framework-proxy] - Proxy to redirect incoming request to another API server. * [django-rest-framework-proxy][django-rest-framework-proxy] - Proxy to redirect incoming request to another API server.
* [gaiarestframework][gaiarestframework] - Utils for django-rest-framewok * [gaiarestframework][gaiarestframework] - Utils for django-rest-framework
* [drf-extensions][drf-extensions] - A collection of custom extensions * [drf-extensions][drf-extensions] - A collection of custom extensions
* [ember-django-adapter][ember-django-adapter] - An adapter for working with Ember.js * [ember-django-adapter][ember-django-adapter] - An adapter for working with Ember.js
* [django-versatileimagefield][django-versatileimagefield] - Provides a drop-in replacement for Django's stock `ImageField` that makes it easy to serve images in multiple sizes/renditions from a single field. For DRF-specific implementation docs, [click here][django-versatileimagefield-drf-docs].
* [drf-tracking][drf-tracking] - Utilities to track requests to DRF API views.
* [django-rest-framework-braces][django-rest-framework-braces] - Collection of utilities for working with Django Rest Framework. The most notable ones are [FormSerializer](https://django-rest-framework-braces.readthedocs.org/en/latest/overview.html#formserializer) and [SerializerForm](https://django-rest-framework-braces.readthedocs.org/en/latest/overview.html#serializerform), which are adapters between DRF serializers and Django forms.
## Other Resources ## Other Resources
...@@ -265,6 +270,9 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque ...@@ -265,6 +270,9 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
* [Web API performance: profiling Django REST framework][web-api-performance-profiling-django-rest-framework] * [Web API performance: profiling Django REST framework][web-api-performance-profiling-django-rest-framework]
* [API Development with Django and Django REST Framework][api-development-with-django-and-django-rest-framework] * [API Development with Django and Django REST Framework][api-development-with-django-and-django-rest-framework]
### Documentations
* [Classy Django REST Framework][cdrf.co]
[cite]: http://www.software-ecosystems.com/Software_Ecosystems/Ecosystems.html [cite]: http://www.software-ecosystems.com/Software_Ecosystems/Ecosystems.html
[cookiecutter]: https://github.com/jpadilla/cookiecutter-django-rest-framework [cookiecutter]: https://github.com/jpadilla/cookiecutter-django-rest-framework
[new-repo]: https://github.com/new [new-repo]: https://github.com/new
...@@ -297,6 +305,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque ...@@ -297,6 +305,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
[drf-compound-fields]: https://github.com/estebistec/drf-compound-fields [drf-compound-fields]: https://github.com/estebistec/drf-compound-fields
[django-extra-fields]: https://github.com/Hipo/drf-extra-fields [django-extra-fields]: https://github.com/Hipo/drf-extra-fields
[djangorestframework-bulk]: https://github.com/miki725/django-rest-framework-bulk [djangorestframework-bulk]: https://github.com/miki725/django-rest-framework-bulk
[django-rest-multiple-models]: https://github.com/Axiologue/DjangoRestMultipleModels
[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers [drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
[wq.db.rest]: http://wq.io/docs/about-rest [wq.db.rest]: http://wq.io/docs/about-rest
[djangorestframework-msgpack]: https://github.com/juanriaza/django-rest-framework-msgpack [djangorestframework-msgpack]: https://github.com/juanriaza/django-rest-framework-msgpack
...@@ -326,3 +335,8 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque ...@@ -326,3 +335,8 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
[web-api-performance-profiling-django-rest-framework]: http://dabapps.com/blog/api-performance-profiling-django-rest-framework/ [web-api-performance-profiling-django-rest-framework]: http://dabapps.com/blog/api-performance-profiling-django-rest-framework/
[api-development-with-django-and-django-rest-framework]: https://bnotions.com/api-development-with-django-and-django-rest-framework/ [api-development-with-django-and-django-rest-framework]: https://bnotions.com/api-development-with-django-and-django-rest-framework/
[django-rest-auth]: https://github.com/Tivix/django-rest-auth/ [django-rest-auth]: https://github.com/Tivix/django-rest-auth/
[django-versatileimagefield]: https://github.com/WGBH/django-versatileimagefield
[django-versatileimagefield-drf-docs]:http://django-versatileimagefield.readthedocs.org/en/latest/drf_integration.html
[cdrf.co]:http://www.cdrf.co
[drf-tracking]: https://github.com/aschn/drf-tracking
[django-rest-framework-braces]: https://github.com/dealertrack/django-rest-framework-braces
...@@ -28,11 +28,11 @@ Some example output from our serializer. ...@@ -28,11 +28,11 @@ Some example output from our serializer.
{ {
'title': 'Leaving party preperations', 'title': 'Leaving party preperations',
'items': { 'items': [
{'text': 'Compile playlist', 'is_completed': True}, {'text': 'Compile playlist', 'is_completed': True},
{'text': 'Send invites', 'is_completed': False}, {'text': 'Send invites', 'is_completed': False},
{'text': 'Clean house', 'is_completed': False} {'text': 'Clean house', 'is_completed': False}
} ]
} }
Let's take a look at updating our nested one-to-many data structure. Let's take a look at updating our nested one-to-many data structure.
......
...@@ -89,7 +89,6 @@ We'll also need to create an initial migration for our snippet model, and sync t ...@@ -89,7 +89,6 @@ We'll also need to create an initial migration for our snippet model, and sync t
The first thing we need to get started on our Web API is to provide a way of serializing and deserializing the snippet instances into representations such as `json`. We can do this by declaring serializers that work very similar to Django's forms. Create a file in the `snippets` directory named `serializers.py` and add the following. The first thing we need to get started on our Web API is to provide a way of serializing and deserializing the snippet instances into representations such as `json`. We can do this by declaring serializers that work very similar to Django's forms. Create a file in the `snippets` directory named `serializers.py` and add the following.
from django.forms import widgets
from rest_framework import serializers from rest_framework import serializers
from snippets.models import Snippet, LANGUAGE_CHOICES, STYLE_CHOICES from snippets.models import Snippet, LANGUAGE_CHOICES, STYLE_CHOICES
...@@ -124,7 +123,7 @@ The first part of the serializer class defines the fields that get serialized/de ...@@ -124,7 +123,7 @@ The first part of the serializer class defines the fields that get serialized/de
A serializer class is very similar to a Django `Form` class, and includes similar validation flags on the various fields, such as `required`, `max_length` and `default`. A serializer class is very similar to a Django `Form` class, and includes similar validation flags on the various fields, such as `required`, `max_length` and `default`.
The field flags can also control how the serializer should be displayed in certain circumstances, such as when rendering to HTML. The `{'base_template': 'textarea.html'}` flag above is equivelent to using `widget=widgets.Textarea` on a Django `Form` class. This is particularly useful for controlling how the browsable API should be displayed, as we'll see later in the tutorial. The field flags can also control how the serializer should be displayed in certain circumstances, such as when rendering to HTML. The `{'base_template': 'textarea.html'}` flag above is equivalent to using `widget=widgets.Textarea` on a Django `Form` class. This is particularly useful for controlling how the browsable API should be displayed, as we'll see later in the tutorial.
We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit. We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit.
......
...@@ -108,7 +108,7 @@ and ...@@ -108,7 +108,7 @@ and
Now update the `urls.py` file slightly, to append a set of `format_suffix_patterns` in addition to the existing URLs. Now update the `urls.py` file slightly, to append a set of `format_suffix_patterns` in addition to the existing URLs.
from django.conf.urls import patterns, url from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns from rest_framework.urlpatterns import format_suffix_patterns
from snippets import views from snippets import views
...@@ -200,7 +200,7 @@ See the [browsable api][browsable-api] topic for more information about the brow ...@@ -200,7 +200,7 @@ See the [browsable api][browsable-api] topic for more information about the brow
In [tutorial part 3][tut-3], we'll start using class based views, and see how generic views reduce the amount of code we need to write. In [tutorial part 3][tut-3], we'll start using class based views, and see how generic views reduce the amount of code we need to write.
[json-url]: http://example.com/api/items/4.json [json-url]: http://example.com/api/items/4/.json
[devserver]: http://127.0.0.1:8000/snippets/ [devserver]: http://127.0.0.1:8000/snippets/
[browsable-api]: ../topics/browsable-api.md [browsable-api]: ../topics/browsable-api.md
[tut-1]: 1-serialization.md [tut-1]: 1-serialization.md
......
...@@ -18,7 +18,7 @@ Right now we have endpoints for 'snippets' and 'users', but we don't have a sing ...@@ -18,7 +18,7 @@ Right now we have endpoints for 'snippets' and 'users', but we don't have a sing
'snippets': reverse('snippet-list', request=request, format=format) 'snippets': reverse('snippet-list', request=request, format=format)
}) })
Notice that we're using REST framework's `reverse` function in order to return fully-qualified URLs. Two things should be noticed here. First, we're using REST framework's `reverse` function in order to return fully-qualified URLs; second, URL patterns are identified by convenience names that we will declare later on in our `snippets/urls.py`.
## Creating an endpoint for the highlighted snippets ## Creating an endpoint for the highlighted snippets
...@@ -104,9 +104,11 @@ If we're going to have a hyperlinked API, we need to make sure we name our URL p ...@@ -104,9 +104,11 @@ If we're going to have a hyperlinked API, we need to make sure we name our URL p
* Our user serializer includes a field that refers to `'snippet-detail'`. * Our user serializer includes a field that refers to `'snippet-detail'`.
* Our snippet and user serializers include `'url'` fields that by default will refer to `'{model_name}-detail'`, which in this case will be `'snippet-detail'` and `'user-detail'`. * Our snippet and user serializers include `'url'` fields that by default will refer to `'{model_name}-detail'`, which in this case will be `'snippet-detail'` and `'user-detail'`.
After adding all those names into our URLconf, our final `snippets/urls.py` file should look something like this: After adding all those names into our URLconf, our final `snippets/urls.py` file should look like this:
from django.conf.urls import url, include from django.conf.urls import url, include
from rest_framework.urlpatterns import format_suffix_patterns
from snippets import views
# API endpoints # API endpoints
urlpatterns = format_suffix_patterns([ urlpatterns = format_suffix_patterns([
...@@ -141,7 +143,7 @@ The list views for users and code snippets could end up returning quite a lot of ...@@ -141,7 +143,7 @@ The list views for users and code snippets could end up returning quite a lot of
We can change the default list style to use pagination, by modifying our `tutorial/settings.py` file slightly. Add the following setting: We can change the default list style to use pagination, by modifying our `tutorial/settings.py` file slightly. Add the following setting:
REST_FRAMEWORK = { REST_FRAMEWORK = {
'PAGINATE_BY': 10 'PAGE_SIZE': 10
} }
Note that settings in REST framework are all namespaced into a single dictionary setting, named 'REST_FRAMEWORK', which helps keep them well separated from your other project settings. Note that settings in REST framework are all namespaced into a single dictionary setting, named 'REST_FRAMEWORK', which helps keep them well separated from your other project settings.
......
...@@ -83,8 +83,6 @@ Rather than write multiple views we're grouping together all the common behavior ...@@ -83,8 +83,6 @@ Rather than write multiple views we're grouping together all the common behavior
We can easily break these down into individual views if we need to, but using viewsets keeps the view logic nicely organized as well as being very concise. We can easily break these down into individual views if we need to, but using viewsets keeps the view logic nicely organized as well as being very concise.
Notice that our viewset classes here are a little different from those in the [frontpage example][readme-example-api], as they include `queryset` and `serializer_class` attributes, instead of a `model` attribute.
For trivial cases you can simply set a `model` attribute on the `ViewSet` class and the serializer and queryset will be automatically generated for you. Setting the `queryset` and/or `serializer_class` attributes gives you more explicit control of the API behaviour, and is the recommended style for most applications. For trivial cases you can simply set a `model` attribute on the `ViewSet` class and the serializer and queryset will be automatically generated for you. Setting the `queryset` and/or `serializer_class` attributes gives you more explicit control of the API behaviour, and is the recommended style for most applications.
## URLs ## URLs
...@@ -123,7 +121,7 @@ We'd also like to set a few global settings. We'd like to turn on pagination, a ...@@ -123,7 +121,7 @@ We'd also like to set a few global settings. We'd like to turn on pagination, a
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',), 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',),
'PAGINATE_BY': 10 'PAGE_SIZE': 10
} }
Okay, we're done. Okay, we're done.
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{ page_title }}</title> <title>{% if page_title %}{{ page_title }} - {% endif %}{{ site_name }}</title>
<link href="{{ base_url }}/img/favicon.ico" rel="icon" type="image/x-icon"> <link href="{{ base_url }}/img/favicon.ico" rel="icon" type="image/x-icon">
<link rel="canonical" href="{{ canonical_url }}" /> <link rel="canonical" href="{{ canonical_url }}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Django, API, REST, {{ current_page.title }}"> <meta name="description" content="Django, API, REST{% if current_page %}, {{ current_page.title }}{% endif %}">
<meta name="author" content="Tom Christie"> <meta name="author" content="Tom Christie">
<!-- Le styles --> <!-- Le styles -->
...@@ -54,37 +54,27 @@ ...@@ -54,37 +54,27 @@
} }
</style> </style>
</head> </head>
<body onload="prettyPrint()" class="{% if current_page.is_homepage %}index{% endif %}-page"> <body onload="prettyPrint()" class="{% if current_page and current_page.is_homepage %}index{% endif %}-page">
<div class="wrapper"> <div class="wrapper">
{% include "nav.html" %} {% include "nav.html" %}
<div class="body-content"> <div class="body-content">
<div class="container-fluid"> <div class="container-fluid">
<!-- Search Modal --> <!-- Search Modal -->
<div id="searchModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div id="mkdocs_search_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 id="myModalLabel">Documentation search</h3> <h3 id="myModalLabel">Documentation search</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<!-- Custom google search --> <form role="form">
<script> <div class="form-group">
(function() { <input type="text" name="q" class="form-control" placeholder="Search..." id="mkdocs-search-query">
var cx = '015016005043623903336:rxraeohqk6w'; </div>
var gcse = document.createElement('script'); </form>
gcse.type = 'text/javascript'; <div id="mkdocs-search-results"></div>
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
...@@ -93,26 +83,17 @@ ...@@ -93,26 +83,17 @@
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<div class="span3"> <div class="span3">
<!-- TODO
<p style="margin-top: -12px">
<a class="btn btn-mini btn-primary" style="width: 60px">&laquo; previous</a>
<a class="btn btn-mini btn-primary" style="float: right; margin-right: 8px; width: 60px;">next &raquo;</a>
</p>
-->
<div id="table-of-contents"> <div id="table-of-contents">
<ul class="nav nav-list side-nav well sidebar-nav-fixed"> <ul class="nav nav-list side-nav well sidebar-nav-fixed">
{% if current_page and current_page.is_homepage %}
{% if current_page.is_homepage %} <li class="main">
<li class="main"> <a href="#">Django REST framework</a>
<a href="#">Django REST framework</a> </li>
</li>
{% endif %} {% endif %}
{% for toc_item in toc %} {% for toc_item in toc %}
<li class="{% if current_page and not current_page.is_homepage %}main{% endif %}">
<li class="{% if not current_page.is_homepage %}main{% endif %}">
<a href="{{ toc_item.url }}">{{ toc_item.title }}</a> <a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
</li> </li>
...@@ -121,42 +102,38 @@ ...@@ -121,42 +102,38 @@
<a href="{{ toc_item.url }}">{{ toc_item.title }}</a> <a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
</li> </li>
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% if current_page.is_homepage %} {% if current_page and current_page.is_homepage %}
<div class="promo"> <div class="promo">
<hr/> <hr/>
<script type="text/javascript" src="//cdn.fusionads.net/fusion.js?zoneid=1332&serve=C6SDP2Y&placement=djangorestframework" id="_fusionads_js"></script> <script type="text/javascript" src="//cdn.fusionads.net/fusion.js?zoneid=1332&serve=C6SDP2Y&placement=djangorestframework" id="_fusionads_js"></script>
</div> </div>
{% endif %} {% endif %}
</ul> </ul>
</div> </div>
</div> </div>
<div id="main-content" class="span9"> <div id="main-content" class="span9">
{% if meta.source %} {% block content %}
{% for filename in meta.source %} {% if meta.source %}
<a class="github" href="https://github.com/tomchristie/django-rest-framework/tree/master/rest_framework/{{ filename }}"> {% for filename in meta.source %}
<span class="label label-info">{{ filename }}</span> <a class="github" href="https://github.com/tomchristie/django-rest-framework/tree/master/rest_framework/{{ filename }}">
</a> <span class="label label-info">{{ filename }}</span>
{% endfor %} </a>
{% endif %} {% endfor %}
{% endif %}
{{ content }}
</div> {{ content }}
<!--/span--> {% endblock %}
</div>
<!--/row--> </div> <!--/span-->
</div> </div> <!--/row-->
<!--/.fluid-container--> </div> <!--/.fluid-container-->
</div> </div> <!--/.body content-->
<!--/.body content-->
<div id="push"></div> <div id="push"></div>
</div> </div> <!--/.wrapper -->
<!--/.wrapper -->
<footer class="span12"> <footer class="span12">
<p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</a> <p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</a>
...@@ -169,13 +146,15 @@ ...@@ -169,13 +146,15 @@
<script src="{{ base_url }}/js/jquery-1.8.1-min.js"></script> <script src="{{ base_url }}/js/jquery-1.8.1-min.js"></script>
<script src="{{ base_url }}/js/prettify-1.0.js"></script> <script src="{{ base_url }}/js/prettify-1.0.js"></script>
<script src="{{ base_url }}/js/bootstrap-2.1.1-min.js"></script> <script src="{{ base_url }}/js/bootstrap-2.1.1-min.js"></script>
<script>var base_url = '{{ base_url }}';</script>
<script src="{{ base_url }}/mkdocs/js/require.js"></script>
<script src="{{ base_url }}/js/theme.js"></script> <script src="{{ base_url }}/js/theme.js"></script>
<script> <script>
//$('.side-nav').scrollspy()
var shiftWindow = function() { var shiftWindow = function() {
scrollBy(0, -50) scrollBy(0, -50)
}; };
if (location.hash) shiftWindow(); if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow); window.addEventListener("hashchange", shiftWindow);
...@@ -183,12 +162,12 @@ ...@@ -183,12 +162,12 @@
event.stopPropagation(); event.stopPropagation();
}); });
// Dynamically force sidenav to no higher than browser window // Dynamically force sidenav/dropdown to no higher than browser window
$('.side-nav').css('max-height', window.innerHeight - 130); $('.side-nav, .dropdown-menu').css('max-height', window.innerHeight - 130);
$(function() { $(function() {
$(window).resize(function() { $(window).resize(function() {
$('.side-nav').css('max-height', window.innerHeight - 130); $('.side-nav, .dropdown-menu').css('max-height', window.innerHeight - 130);
}); });
}); });
</script> </script>
......
...@@ -5,11 +5,12 @@ pre { ...@@ -5,11 +5,12 @@ pre {
} }
.dropdown .dropdown-menu { .dropdown .dropdown-menu {
display: none; display: none;
overflow-y: scroll;
} }
.dropdown.open .dropdown-menu { .dropdown.open .dropdown-menu {
display: block; display: block;
} }
@media (max-width: 480px) { @media (max-width: 480px) {
...@@ -36,15 +37,8 @@ body.index-page #main-content iframe.github-star-button { ...@@ -36,15 +37,8 @@ body.index-page #main-content iframe.github-star-button {
margin-right: -15px; margin-right: -15px;
} }
/* Tweet button */ /* Travis CI and PyPI badge */
body.index-page #main-content iframe.twitter-share-button { body.index-page #main-content img.status-badge {
float: right;
margin-top: -12px;
margin-right: 8px;
}
/* Travis CI badge */
body.index-page #main-content img.travis-build-image {
float: right; float: right;
margin-right: 8px; margin-right: 8px;
margin-top: -11px; margin-top: -11px;
...@@ -415,3 +409,7 @@ ul.sponsor { ...@@ -415,3 +409,7 @@ ul.sponsor {
list-style: none; list-style: none;
display: block; display: block;
} }
#mkdocs_search_modal article p{
word-wrap: break-word;
}
$(function(){ function getSearchTerm()
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == 'q')
{
return sParameterName[1];
}
}
}
$(function() {
var initialise_search = function(){
require.config({"baseUrl":"/mkdocs/js"});
require(["search",]);
}
var search_term = getSearchTerm();
if(search_term){
$('#mkdocs_search_modal').modal();
}
$('pre code').parent().addClass('prettyprint well'); $('pre code').parent().addClass('prettyprint well');
$(document).on("submit", "#mkdocs_search_modal form", function (e) {
$("#mkdocs-search-results").html("Searching...");
initialise_search();
return false;
});
}); });
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<a class="repo-link btn btn-inverse btn-small {% if not previous_page %}disabled{% endif %}" rel="next" {% if previous_page %}href="{{ previous_page.url }}"{% endif %}> <a class="repo-link btn btn-inverse btn-small {% if not previous_page %}disabled{% endif %}" rel="next" {% if previous_page %}href="{{ previous_page.url }}"{% endif %}>
<i class="icon-arrow-left icon-white"></i> Previous <i class="icon-arrow-left icon-white"></i> Previous
</a> </a>
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a> <a id="search_modal_show" class="repo-link btn btn-inverse btn-small" href="#mkdocs_search_modal" data-toggle="modal" data-target="#mkdocs_search_modal"><i class="icon-search icon-white"></i> Search</a>
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
{% if include_nav %} {% if include_nav %}
<!-- Main navigation --> <!-- Main navigation -->
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li {% if current_page.is_homepage %}class="active"{% endif %}><a href="/">Home</a></li>
{% for nav_item in nav %} {% if nav_item.children %} {% for nav_item in nav %} {% if nav_item.children %}
<li class="dropdown{% if nav_item.active %} active{% endif %}"> <li class="dropdown{% if nav_item.active %} active{% endif %}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
......
...@@ -7,50 +7,53 @@ repo_url: https://github.com/tomchristie/django-rest-framework ...@@ -7,50 +7,53 @@ repo_url: https://github.com/tomchristie/django-rest-framework
theme_dir: docs_theme theme_dir: docs_theme
pages: pages:
- ['index.md', 'Home'] - Home: 'index.md'
- ['tutorial/quickstart.md', 'Tutorial', 'Quickstart'] - Tutorial:
- ['tutorial/1-serialization.md', 'Tutorial', '1 - Serialization'] - 'Quickstart': 'tutorial/quickstart.md'
- ['tutorial/2-requests-and-responses.md', 'Tutorial', '2 - Requests and responses'] - '1 - Serialization': 'tutorial/1-serialization.md'
- ['tutorial/3-class-based-views.md', 'Tutorial', '3 - Class based views'] - '2 - Requests and responses': 'tutorial/2-requests-and-responses.md'
- ['tutorial/4-authentication-and-permissions.md', 'Tutorial', '4 - Authentication and permissions'] - '3 - Class based views': 'tutorial/3-class-based-views.md'
- ['tutorial/5-relationships-and-hyperlinked-apis.md', 'Tutorial', '5 - Relationships and hyperlinked APIs'] - '4 - Authentication and permissions': 'tutorial/4-authentication-and-permissions.md'
- ['tutorial/6-viewsets-and-routers.md', 'Tutorial', '6 - Viewsets and routers'] - '5 - Relationships and hyperlinked APIs': 'tutorial/5-relationships-and-hyperlinked-apis.md'
- ['api-guide/requests.md', 'API Guide', 'Requests'] - '6 - Viewsets and routers': 'tutorial/6-viewsets-and-routers.md'
- ['api-guide/responses.md', 'API Guide', 'Responses'] - API Guide:
- ['api-guide/views.md', 'API Guide', 'Views'] - 'Requests': 'api-guide/requests.md'
- ['api-guide/generic-views.md', 'API Guide', 'Generic views'] - 'Responses': 'api-guide/responses.md'
- ['api-guide/viewsets.md', 'API Guide', 'Viewsets'] - 'Views': 'api-guide/views.md'
- ['api-guide/routers.md', 'API Guide', 'Routers'] - 'Generic views': 'api-guide/generic-views.md'
- ['api-guide/parsers.md', 'API Guide', 'Parsers'] - 'Viewsets': 'api-guide/viewsets.md'
- ['api-guide/renderers.md', 'API Guide', 'Renderers'] - 'Routers': 'api-guide/routers.md'
- ['api-guide/serializers.md', 'API Guide', 'Serializers'] - 'Parsers': 'api-guide/parsers.md'
- ['api-guide/fields.md', 'API Guide', 'Serializer fields'] - 'Renderers': 'api-guide/renderers.md'
- ['api-guide/relations.md', 'API Guide', 'Serializer relations'] - 'Serializers': 'api-guide/serializers.md'
- ['api-guide/validators.md', 'API Guide', 'Validators'] - 'Serializer fields': 'api-guide/fields.md'
- ['api-guide/authentication.md', 'API Guide', 'Authentication'] - 'Serializer relations': 'api-guide/relations.md'
- ['api-guide/permissions.md', 'API Guide', 'Permissions'] - 'Validators': 'api-guide/validators.md'
- ['api-guide/throttling.md', 'API Guide', 'Throttling'] - 'Authentication': 'api-guide/authentication.md'
- ['api-guide/filtering.md', 'API Guide', 'Filtering'] - 'Permissions': 'api-guide/permissions.md'
- ['api-guide/pagination.md', 'API Guide', 'Pagination'] - 'Throttling': 'api-guide/throttling.md'
- ['api-guide/versioning.md', 'API Guide', 'Versioning'] - 'Filtering': 'api-guide/filtering.md'
- ['api-guide/content-negotiation.md', 'API Guide', 'Content negotiation'] - 'Pagination': 'api-guide/pagination.md'
- ['api-guide/metadata.md', 'API Guide', 'Metadata'] - 'Versioning': 'api-guide/versioning.md'
- ['api-guide/format-suffixes.md', 'API Guide', 'Format suffixes'] - 'Content negotiation': 'api-guide/content-negotiation.md'
- ['api-guide/reverse.md', 'API Guide', 'Returning URLs'] - 'Metadata': 'api-guide/metadata.md'
- ['api-guide/exceptions.md', 'API Guide', 'Exceptions'] - 'Format suffixes': 'api-guide/format-suffixes.md'
- ['api-guide/status-codes.md', 'API Guide', 'Status codes'] - 'Returning URLs': 'api-guide/reverse.md'
- ['api-guide/testing.md', 'API Guide', 'Testing'] - 'Exceptions': 'api-guide/exceptions.md'
- ['api-guide/settings.md', 'API Guide', 'Settings'] - 'Status codes': 'api-guide/status-codes.md'
- ['topics/documenting-your-api.md', 'Topics', 'Documenting your API'] - 'Testing': 'api-guide/testing.md'
- ['topics/internationalization.md', 'Topics', 'Internationalization'] - 'Settings': 'api-guide/settings.md'
- ['topics/ajax-csrf-cors.md', 'Topics', 'AJAX, CSRF & CORS'] - Topics:
- ['topics/browser-enhancements.md', 'Topics',] - 'Documenting your API': 'topics/documenting-your-api.md'
- ['topics/browsable-api.md', 'Topics', 'The Browsable API'] - 'Internationalization': 'topics/internationalization.md'
- ['topics/rest-hypermedia-hateoas.md', 'Topics', 'REST, Hypermedia & HATEOAS'] - 'AJAX, CSRF & CORS': 'topics/ajax-csrf-cors.md'
- ['topics/third-party-resources.md', 'Topics', 'Third Party Resources'] - 'Browser Enhancements': 'topics/browser-enhancements.md'
- ['topics/contributing.md', 'Topics', 'Contributing to REST framework'] - 'The Browsable API': 'topics/browsable-api.md'
- ['topics/project-management.md', 'Topics', 'Project management'] - 'REST, Hypermedia & HATEOAS': 'topics/rest-hypermedia-hateoas.md'
- ['topics/3.0-announcement.md', 'Topics', '3.0 Announcement'] - 'Third Party Resources': 'topics/third-party-resources.md'
- ['topics/3.1-announcement.md', 'Topics', '3.1 Announcement'] - 'Contributing to REST framework': 'topics/contributing.md'
- ['topics/kickstarter-announcement.md', 'Topics', 'Kickstarter Announcement'] - 'Project management': 'topics/project-management.md'
- ['topics/release-notes.md', 'Topics', 'Release Notes'] - '3.0 Announcement': 'topics/3.0-announcement.md'
- '3.1 Announcement': 'topics/3.1-announcement.md'
- 'Kickstarter Announcement': 'topics/kickstarter-announcement.md'
- 'Release Notes': 'topics/release-notes.md'
# PEP8 code linting, which we run on all commits. # PEP8 code linting, which we run on all commits.
flake8==2.3.0 flake8==2.4.0
pep8==1.6.2 pep8==1.5.7
# Sort and lint imports
isort==3.9.6
# MkDocs to build our documentation. # MkDocs to build our documentation.
mkdocs==0.11.1 mkdocs==0.13.2
# Optional packages which may be used with REST framework. # Optional packages which may be used with REST framework.
markdown==2.5.2 markdown==2.5.2
django-guardian==1.2.5 django-guardian==1.3.0
django-filter==0.9.2 django-filter==0.10.0
# PyTest for running the tests. # PyTest for running the tests.
pytest==2.6.4 pytest==2.6.4
pytest-django==2.8.0 pytest-django==2.8.0
pytest-cov==1.8.1
...@@ -8,7 +8,7 @@ ______ _____ _____ _____ __ ...@@ -8,7 +8,7 @@ ______ _____ _____ _____ __
""" """
__title__ = 'Django REST framework' __title__ = 'Django REST framework'
__version__ = '3.1.0' __version__ = '3.1.3'
__author__ = 'Tom Christie' __author__ = 'Tom Christie'
__license__ = 'BSD 2-Clause' __license__ = 'BSD 2-Clause'
__copyright__ = 'Copyright 2011-2015 Tom Christie' __copyright__ = 'Copyright 2011-2015 Tom Christie'
......
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
Provides various authentication policies. Provides various authentication policies.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
import base64 import base64
from django.contrib.auth import authenticate from django.contrib.auth import authenticate
from django.middleware.csrf import CsrfViewMiddleware from django.middleware.csrf import CsrfViewMiddleware
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import exceptions, HTTP_HEADER_ENCODING
from rest_framework import HTTP_HEADER_ENCODING, exceptions
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
from rest_framework.compat import get_user_model
def get_authorization_header(request): def get_authorization_header(request):
...@@ -85,7 +89,12 @@ class BasicAuthentication(BaseAuthentication): ...@@ -85,7 +89,12 @@ class BasicAuthentication(BaseAuthentication):
""" """
Authenticate the userid and password against username and password. Authenticate the userid and password against username and password.
""" """
user = authenticate(username=userid, password=password) username_field = getattr(get_user_model(), 'USERNAME_FIELD', 'username')
credentials = {
username_field: userid,
'password': password
}
user = authenticate(**credentials)
if user is None: if user is None:
raise exceptions.AuthenticationFailed(_('Invalid username/password.')) raise exceptions.AuthenticationFailed(_('Invalid username/password.'))
...@@ -164,7 +173,13 @@ class TokenAuthentication(BaseAuthentication): ...@@ -164,7 +173,13 @@ class TokenAuthentication(BaseAuthentication):
msg = _('Invalid token header. Token string should not contain spaces.') msg = _('Invalid token header. Token string should not contain spaces.')
raise exceptions.AuthenticationFailed(msg) raise exceptions.AuthenticationFailed(msg)
return self.authenticate_credentials(auth[1]) try:
token = auth[1].decode()
except UnicodeError:
msg = _('Invalid token header. Token string should not contain invalid characters.')
raise exceptions.AuthenticationFailed(msg)
return self.authenticate_credentials(token)
def authenticate_credentials(self, key): def authenticate_credentials(self, key):
try: try:
......
from django.contrib import admin from django.contrib import admin
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
......
...@@ -5,7 +5,6 @@ from django.conf import settings ...@@ -5,7 +5,6 @@ from django.conf import settings
from django.db import models from django.db import models
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist. # Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
# Note that we don't perform this code in the compat module due to # Note that we don't perform this code in the compat module due to
# bug report #1297 # bug report #1297
......
...@@ -6,7 +6,7 @@ from rest_framework import exceptions, serializers ...@@ -6,7 +6,7 @@ from rest_framework import exceptions, serializers
class AuthTokenSerializer(serializers.Serializer): class AuthTokenSerializer(serializers.Serializer):
username = serializers.CharField() username = serializers.CharField()
password = serializers.CharField() password = serializers.CharField(style={'input_type': 'password'})
def validate(self, attrs): def validate(self, attrs):
username = attrs.get('username') username = attrs.get('username')
......
from rest_framework.views import APIView from rest_framework import parsers, renderers
from rest_framework import parsers
from rest_framework import renderers
from rest_framework.response import Response
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
from rest_framework.authtoken.serializers import AuthTokenSerializer from rest_framework.authtoken.serializers import AuthTokenSerializer
from rest_framework.response import Response
from rest_framework.views import APIView
class ObtainAuthToken(APIView): class ObtainAuthToken(APIView):
...@@ -11,9 +10,10 @@ class ObtainAuthToken(APIView): ...@@ -11,9 +10,10 @@ class ObtainAuthToken(APIView):
permission_classes = () permission_classes = ()
parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,) parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
renderer_classes = (renderers.JSONRenderer,) renderer_classes = (renderers.JSONRenderer,)
serializer_class = AuthTokenSerializer
def post(self, request): def post(self, request):
serializer = AuthTokenSerializer(data=request.data) serializer = self.serializer_class(data=request.data)
serializer.is_valid(raise_exception=True) serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user'] user = serializer.validated_data['user']
token, created = Token.objects.get_or_create(user=user) token, created = Token.objects.get_or_create(user=user)
......
...@@ -5,13 +5,18 @@ versions of django/python, and compatibility wrappers around optional packages. ...@@ -5,13 +5,18 @@ versions of django/python, and compatibility wrappers around optional packages.
# flake8: noqa # flake8: noqa
from __future__ import unicode_literals from __future__ import unicode_literals
from django.core.exceptions import ImproperlyConfigured
import inspect
import django
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import connection, transaction
from django.test.client import FakePayload
from django.utils import six
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.six.moves.urllib.parse import urlparse as _urlparse from django.utils.six.moves.urllib.parse import urlparse as _urlparse
from django.utils import six
import django
import inspect
try: try:
import importlib import importlib
except ImportError: except ImportError:
...@@ -119,6 +124,14 @@ def get_model_name(model_cls): ...@@ -119,6 +124,14 @@ def get_model_name(model_cls):
return model_cls._meta.module_name return model_cls._meta.module_name
# Support custom user models in Django 1.5+
try:
from django.contrib.auth import get_user_model
except ImportError:
from django.contrib.auth.models import User
get_user_model = lambda: User
# View._allowed_methods only present from 1.5 onwards # View._allowed_methods only present from 1.5 onwards
if django.VERSION >= (1, 5): if django.VERSION >= (1, 5):
from django.views.generic import View from django.views.generic import View
...@@ -190,9 +203,6 @@ if 'patch' not in View.http_method_names: ...@@ -190,9 +203,6 @@ if 'patch' not in View.http_method_names:
View.http_method_names = View.http_method_names + ['patch'] View.http_method_names = View.http_method_names + ['patch']
# RequestFactory only provides `generic` from 1.5 onwards
from django.test.client import RequestFactory as DjangoRequestFactory
from django.test.client import FakePayload
try: try:
# In 1.5 the test client uses force_bytes # In 1.5 the test client uses force_bytes
...@@ -202,24 +212,30 @@ except ImportError: ...@@ -202,24 +212,30 @@ except ImportError:
from django.utils.encoding import smart_str as force_bytes_or_smart_bytes from django.utils.encoding import smart_str as force_bytes_or_smart_bytes
class RequestFactory(DjangoRequestFactory): # RequestFactory only provides `generic` from 1.5 onwards
def generic(self, method, path, if django.VERSION >= (1, 5):
data='', content_type='application/octet-stream', **extra): from django.test.client import RequestFactory
parsed = _urlparse(path) else:
data = force_bytes_or_smart_bytes(data, settings.DEFAULT_CHARSET) from django.test.client import RequestFactory as DjangoRequestFactory
r = {
'PATH_INFO': self._get_path(parsed), class RequestFactory(DjangoRequestFactory):
'QUERY_STRING': force_text(parsed[4]), def generic(self, method, path,
'REQUEST_METHOD': six.text_type(method), data='', content_type='application/octet-stream', **extra):
} parsed = _urlparse(path)
if data: data = force_bytes_or_smart_bytes(data, settings.DEFAULT_CHARSET)
r.update({ r = {
'CONTENT_LENGTH': len(data), 'PATH_INFO': self._get_path(parsed),
'CONTENT_TYPE': six.text_type(content_type), 'QUERY_STRING': force_text(parsed[4]),
'wsgi.input': FakePayload(data), 'REQUEST_METHOD': six.text_type(method),
}) }
r.update(extra) if data:
return self.request(**r) r.update({
'CONTENT_LENGTH': len(data),
'CONTENT_TYPE': six.text_type(content_type),
'wsgi.input': FakePayload(data),
})
r.update(extra)
return self.request(**r)
# Markdown is optional # Markdown is optional
...@@ -250,3 +266,28 @@ else: ...@@ -250,3 +266,28 @@ else:
SHORT_SEPARATORS = (b',', b':') SHORT_SEPARATORS = (b',', b':')
LONG_SEPARATORS = (b', ', b': ') LONG_SEPARATORS = (b', ', b': ')
INDENT_SEPARATORS = (b',', b': ') INDENT_SEPARATORS = (b',', b': ')
if django.VERSION >= (1, 8):
from django.db.models import DurationField
from django.utils.dateparse import parse_duration
from django.utils.duration import duration_string
else:
DurationField = duration_string = parse_duration = None
def set_rollback():
if hasattr(transaction, 'set_rollback'):
if connection.settings_dict.get('ATOMIC_REQUESTS', False):
# If running in >=1.6 then mark a rollback as required,
# and allow it to be handled by Django.
if connection.in_atomic_block:
transaction.set_rollback(True)
elif transaction.is_managed():
# Otherwise handle it explicitly if in managed mode.
if transaction.is_dirty():
transaction.rollback()
transaction.leave_transaction_management()
else:
# transaction not managed
pass
...@@ -7,9 +7,12 @@ based views, as well as the `@detail_route` and `@list_route` decorators, which ...@@ -7,9 +7,12 @@ based views, as well as the `@detail_route` and `@list_route` decorators, which
used to annotate methods on viewsets that should be included by routers. used to annotate methods on viewsets that should be included by routers.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
import types
from django.utils import six from django.utils import six
from rest_framework.views import APIView from rest_framework.views import APIView
import types
def api_view(http_method_names=None): def api_view(http_method_names=None):
......
...@@ -5,11 +5,15 @@ In addition Django's built in 403 and 404 exceptions are handled. ...@@ -5,11 +5,15 @@ In addition Django's built in 403 and 404 exceptions are handled.
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`) (`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
import math
from django.utils import six from django.utils import six
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _, ungettext from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext
from rest_framework import status from rest_framework import status
import math
def _force_text_recursive(data): def _force_text_recursive(data):
......
...@@ -4,13 +4,16 @@ returned by list views. ...@@ -4,13 +4,16 @@ returned by list views.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
import operator
from functools import reduce
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.db import models from django.db import models
from django.utils import six from django.utils import six
from rest_framework.compat import django_filters, guardian, get_model_name
from rest_framework.compat import django_filters, get_model_name, guardian
from rest_framework.settings import api_settings from rest_framework.settings import api_settings
from functools import reduce
import operator
FilterSet = django_filters and django_filters.FilterSet or None FilterSet = django_filters and django_filters.FilterSet or None
...@@ -57,6 +60,7 @@ class DjangoFilterBackend(BaseFilterBackend): ...@@ -57,6 +60,7 @@ class DjangoFilterBackend(BaseFilterBackend):
class Meta: class Meta:
model = queryset.model model = queryset.model
fields = filter_fields fields = filter_fields
return AutoFilterSet return AutoFilterSet
return None return None
...@@ -98,13 +102,20 @@ class SearchFilter(BaseFilterBackend): ...@@ -98,13 +102,20 @@ class SearchFilter(BaseFilterBackend):
if not search_fields: if not search_fields:
return queryset return queryset
original_queryset = queryset
orm_lookups = [self.construct_search(six.text_type(search_field)) orm_lookups = [self.construct_search(six.text_type(search_field))
for search_field in search_fields] for search_field in search_fields]
for search_term in self.get_search_terms(request): for search_term in self.get_search_terms(request):
or_queries = [models.Q(**{orm_lookup: search_term}) or_queries = [models.Q(**{orm_lookup: search_term})
for orm_lookup in orm_lookups] for orm_lookup in orm_lookups]
queryset = queryset.filter(reduce(operator.or_, or_queries)).distinct() queryset = queryset.filter(reduce(operator.or_, or_queries))
if settings.DATABASES[queryset.db]["ENGINE"] == "django.db.backends.oracle":
# distinct analogue for Oracle users
queryset = original_queryset.filter(pk__in=set(queryset.values_list('pk', flat=True)))
else:
queryset = queryset.distinct()
return queryset return queryset
...@@ -187,4 +198,7 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend): ...@@ -187,4 +198,7 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend):
'model_name': get_model_name(model_cls) 'model_name': get_model_name(model_cls)
} }
permission = self.perm_format % kwargs permission = self.perm_format % kwargs
return guardian.shortcuts.get_objects_for_user(user, permission, queryset) if guardian.VERSION >= (1, 3):
# Maintain behavior compatibility with versions prior to 1.3
extra = {'accept_global_perms': False}
return guardian.shortcuts.get_objects_for_user(user, permission, queryset, **extra)
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
Generic views that provide commonly needed behaviour. Generic views that provide commonly needed behaviour.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.http import Http404 from django.http import Http404
from django.shortcuts import get_object_or_404 as _get_object_or_404 from django.shortcuts import get_object_or_404 as _get_object_or_404
from rest_framework import views, mixins
from rest_framework import mixins, views
from rest_framework.settings import api_settings from rest_framework.settings import api_settings
......
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Django REST framework\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: 2015-06-03 16:30+0000\n"
"Last-Translator: Xavier Ordoquy <xordoquy@linovia.com>\n"
"Language-Team: Belarusian (http://www.transifex.com/projects/p/django-rest-framework/language/be/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: be\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"
#: authentication.py:70
msgid "Invalid basic header. No credentials provided."
msgstr ""
#: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr ""
#: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr ""
#: authentication.py:97
msgid "Invalid username/password."
msgstr ""
#: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided."
msgstr ""
#: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces."
msgstr ""
#: authentication.py:179
msgid "Invalid token."
msgstr ""
#: authtoken/serializers.py:20
msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr ""
#: exceptions.py:38
msgid "A server error occurred."
msgstr ""
#: exceptions.py:73
msgid "Malformed request."
msgstr ""
#: exceptions.py:78
msgid "Incorrect authentication credentials."
msgstr ""
#: exceptions.py:83
msgid "Authentication credentials were not provided."
msgstr ""
#: exceptions.py:88
msgid "You do not have permission to perform this action."
msgstr ""
#: exceptions.py:93 views.py:78
msgid "Not found."
msgstr ""
#: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed."
msgstr ""
#: exceptions.py:109
msgid "Could not satisfy the request Accept header."
msgstr ""
#: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request."
msgstr ""
#: exceptions.py:134
msgid "Request was throttled."
msgstr ""
#: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:160
msgid "This field is required."
msgstr ""
#: fields.py:163
msgid "This field may not be null."
msgstr ""
#: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean."
msgstr ""
#: fields.py:559
msgid "This field may not be blank."
msgstr ""
#: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters."
msgstr ""
#: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters."
msgstr ""
#: fields.py:598
msgid "Enter a valid email address."
msgstr ""
#: fields.py:609
msgid "This value does not match the required pattern."
msgstr ""
#: fields.py:620
msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens."
msgstr ""
#: fields.py:632
msgid "Enter a valid URL."
msgstr ""
#: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID."
msgstr ""
#: fields.py:679
msgid "A valid integer is required."
msgstr ""
#: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}."
msgstr ""
#: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}."
msgstr ""
#: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large."
msgstr ""
#: fields.py:714 fields.py:747
msgid "A valid number is required."
msgstr ""
#: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr ""
#: fields.py:751
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_decimal_places} decimal places."
msgstr ""
#: fields.py:752
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point."
msgstr ""
#: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:843
msgid "Expected a datetime but got a date."
msgstr ""
#: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:908
msgid "Expected a date but got a datetime."
msgstr ""
#: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice."
msgstr ""
#: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"."
msgstr ""
#: fields.py:1129
msgid "No file was submitted."
msgstr ""
#: fields.py:1130
msgid ""
"The submitted data was not a file. Check the encoding type on the form."
msgstr ""
#: fields.py:1131
msgid "No filename could be determined."
msgstr ""
#: fields.py:1132
msgid "The submitted file is empty."
msgstr ""
#: fields.py:1133
#, python-brace-format
msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})."
msgstr ""
#: fields.py:1175
msgid ""
"Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image."
msgstr ""
#: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr ""
#: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}."
msgstr ""
#: pagination.py:492
msgid "Invalid cursor"
msgstr ""
#: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr ""
#: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr ""
#: relations.py:157
msgid "Invalid hyperlink - No URL match."
msgstr ""
#: relations.py:158
msgid "Invalid hyperlink - Incorrect URL match."
msgstr ""
#: relations.py:159
msgid "Invalid hyperlink - Object does not exist."
msgstr ""
#: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr ""
#: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist."
msgstr ""
#: relations.py:303
msgid "Invalid value."
msgstr ""
#: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22
msgid "This field must be unique."
msgstr ""
#: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set."
msgstr ""
#: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date."
msgstr ""
#: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month."
msgstr ""
#: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year."
msgstr ""
#: versioning.py:39
msgid "Invalid version in \"Accept\" header."
msgstr ""
#: versioning.py:70 versioning.py:112
msgid "Invalid version in URL path."
msgstr ""
#: versioning.py:141
msgid "Invalid version in hostname."
msgstr ""
#: versioning.py:163
msgid "Invalid version in query parameter."
msgstr ""
#: views.py:85
msgid "Permission denied."
msgstr ""
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-30 16:40+0000\n" "POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -17,36 +17,48 @@ msgstr "" ...@@ -17,36 +17,48 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: authentication.py:69 #: authentication.py:70
msgid "Invalid basic header. No credentials provided." msgid "Invalid basic header. No credentials provided."
msgstr "" msgstr ""
#: authentication.py:72 #: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces." msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr "" msgstr ""
#: authentication.py:78 #: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded." msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr "" msgstr ""
#: authentication.py:90 #: authentication.py:97
msgid "Invalid username/password." msgid "Invalid username/password."
msgstr "" msgstr ""
#: authentication.py:156 #: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided." msgid "Invalid token header. No credentials provided."
msgstr "" msgstr ""
#: authentication.py:159 #: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces." msgid "Invalid token header. Token string should not contain spaces."
msgstr "" msgstr ""
#: authentication.py:168 #: authentication.py:179
msgid "Invalid token." msgid "Invalid token."
msgstr "" msgstr ""
#: authentication.py:171 #: authtoken/serializers.py:20
msgid "User inactive or deleted." msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr "" msgstr ""
#: exceptions.py:38 #: exceptions.py:38
...@@ -69,11 +81,12 @@ msgstr "" ...@@ -69,11 +81,12 @@ msgstr ""
msgid "You do not have permission to perform this action." msgid "You do not have permission to perform this action."
msgstr "" msgstr ""
#: exceptions.py:93 views.py:77 #: exceptions.py:93 views.py:78
msgid "Not found." msgid "Not found."
msgstr "" msgstr ""
#: exceptions.py:98 #: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed." msgid "Method \"{method}\" not allowed."
msgstr "" msgstr ""
...@@ -82,6 +95,7 @@ msgid "Could not satisfy the request Accept header." ...@@ -82,6 +95,7 @@ msgid "Could not satisfy the request Accept header."
msgstr "" msgstr ""
#: exceptions.py:121 #: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request." msgid "Unsupported media type \"{media_type}\" in request."
msgstr "" msgstr ""
...@@ -89,159 +103,183 @@ msgstr "" ...@@ -89,159 +103,183 @@ msgstr ""
msgid "Request was throttled." msgid "Request was throttled."
msgstr "" msgstr ""
#: fields.py:153 relations.py:132 relations.py:156 validators.py:77 #: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:155 #: validators.py:160
msgid "This field is required." msgid "This field is required."
msgstr "" msgstr ""
#: fields.py:154 #: fields.py:163
msgid "This field may not be null." msgid "This field may not be null."
msgstr "" msgstr ""
#: fields.py:487 fields.py:515 #: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean." msgid "\"{input}\" is not a valid boolean."
msgstr "" msgstr ""
#: fields.py:550 #: fields.py:559
msgid "This field may not be blank." msgid "This field may not be blank."
msgstr "" msgstr ""
#: fields.py:551 fields.py:1324 #: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters." msgid "Ensure this field has no more than {max_length} characters."
msgstr "" msgstr ""
#: fields.py:552 #: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters." msgid "Ensure this field has at least {min_length} characters."
msgstr "" msgstr ""
#: fields.py:587 #: fields.py:598
msgid "Enter a valid email address." msgid "Enter a valid email address."
msgstr "" msgstr ""
#: fields.py:604 #: fields.py:609
msgid "This value does not match the required pattern." msgid "This value does not match the required pattern."
msgstr "" msgstr ""
#: fields.py:615 #: fields.py:620
msgid "" msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or " "Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens." "hyphens."
msgstr "" msgstr ""
#: fields.py:627 #: fields.py:632
msgid "Enter a valid URL." msgid "Enter a valid URL."
msgstr "" msgstr ""
#: fields.py:638 #: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID." msgid "\"{value}\" is not a valid UUID."
msgstr "" msgstr ""
#: fields.py:657 #: fields.py:679
msgid "A valid integer is required." msgid "A valid integer is required."
msgstr "" msgstr ""
#: fields.py:658 fields.py:692 fields.py:725 #: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}." msgid "Ensure this value is less than or equal to {max_value}."
msgstr "" msgstr ""
#: fields.py:659 fields.py:693 fields.py:726 #: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}." msgid "Ensure this value is greater than or equal to {min_value}."
msgstr "" msgstr ""
#: fields.py:660 fields.py:694 fields.py:730 #: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large." msgid "String value too large."
msgstr "" msgstr ""
#: fields.py:691 fields.py:724 #: fields.py:714 fields.py:747
msgid "A valid number is required." msgid "A valid number is required."
msgstr "" msgstr ""
#: fields.py:727 #: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total." msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr "" msgstr ""
#: fields.py:728 #: fields.py:751
#, python-brace-format
msgid "Ensure that there are no more than {max_decimal_places} decimal places." msgid "Ensure that there are no more than {max_decimal_places} decimal places."
msgstr "" msgstr ""
#: fields.py:729 #: fields.py:752
#, python-brace-format
msgid "" msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the " "Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point." "decimal point."
msgstr "" msgstr ""
#: fields.py:813 #: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}." msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:814 #: fields.py:843
msgid "Expected a datetime but got a date." msgid "Expected a datetime but got a date."
msgstr "" msgstr ""
#: fields.py:878 #: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}." msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:879 #: fields.py:908
msgid "Expected a date but got a datetime." msgid "Expected a date but got a datetime."
msgstr "" msgstr ""
#: fields.py:936 #: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}." msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:992 fields.py:1036 #: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice." msgid "\"{input}\" is not a valid choice."
msgstr "" msgstr ""
#: fields.py:1037 fields.py:1151 serializers.py:482 #: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"." msgid "Expected a list of items but got type \"{input_type}\"."
msgstr "" msgstr ""
#: fields.py:1067 #: fields.py:1129
msgid "No file was submitted." msgid "No file was submitted."
msgstr "" msgstr ""
#: fields.py:1068 #: fields.py:1130
msgid "The submitted data was not a file. Check the encoding type on the form." msgid "The submitted data was not a file. Check the encoding type on the form."
msgstr "" msgstr ""
#: fields.py:1069 #: fields.py:1131
msgid "No filename could be determined." msgid "No filename could be determined."
msgstr "" msgstr ""
#: fields.py:1070 #: fields.py:1132
msgid "The submitted file is empty." msgid "The submitted file is empty."
msgstr "" msgstr ""
#: fields.py:1071 #: fields.py:1133
#, python-brace-format
msgid "" msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})." "Ensure this filename has at most {max_length} characters (it has {length})."
msgstr "" msgstr ""
#: fields.py:1113 #: fields.py:1175
msgid "" msgid ""
"Upload a valid image. The file you uploaded was either not an image or a " "Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image." "corrupted image."
msgstr "" msgstr ""
#: fields.py:1188 #: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"." msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr "" msgstr ""
#: pagination.py:221 #: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}." msgid "Invalid page \"{page_number}\": {message}."
msgstr "" msgstr ""
#: pagination.py:442 #: pagination.py:492
msgid "Invalid cursor" msgid "Invalid cursor"
msgstr "" msgstr ""
#: relations.py:133 #: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist." msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr "" msgstr ""
#: relations.py:134 #: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}." msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr "" msgstr ""
...@@ -258,38 +296,57 @@ msgid "Invalid hyperlink - Object does not exist." ...@@ -258,38 +296,57 @@ msgid "Invalid hyperlink - Object does not exist."
msgstr "" msgstr ""
#: relations.py:160 #: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}." msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr "" msgstr ""
#: relations.py:295 #: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist." msgid "Object with {slug_name}={value} does not exist."
msgstr "" msgstr ""
#: relations.py:296 #: relations.py:303
msgid "Invalid value." msgid "Invalid value."
msgstr "" msgstr ""
#: serializers.py:299 #: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}." msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22 #: validators.py:22
msgid "This field must be unique." msgid "This field must be unique."
msgstr "" msgstr ""
#: validators.py:76 #: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set." msgid "The fields {field_names} must make a unique set."
msgstr "" msgstr ""
#: validators.py:219 #: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date." msgid "This field must be unique for the \"{date_field}\" date."
msgstr "" msgstr ""
#: validators.py:234 #: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month." msgid "This field must be unique for the \"{date_field}\" month."
msgstr "" msgstr ""
#: validators.py:247 #: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year." msgid "This field must be unique for the \"{date_field}\" year."
msgstr "" msgstr ""
...@@ -301,26 +358,14 @@ msgstr "" ...@@ -301,26 +358,14 @@ msgstr ""
msgid "Invalid version in URL path." msgid "Invalid version in URL path."
msgstr "" msgstr ""
#: versioning.py:138 #: versioning.py:141
msgid "Invalid version in hostname." msgid "Invalid version in hostname."
msgstr "" msgstr ""
#: versioning.py:160 #: versioning.py:163
msgid "Invalid version in query parameter." msgid "Invalid version in query parameter."
msgstr "" msgstr ""
#: views.py:81 #: views.py:85
msgid "Permission denied." msgid "Permission denied."
msgstr "" msgstr ""
#: authtoken/serializers.py:20
msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr ""
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Django REST framework\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: 2015-06-03 16:30+0000\n"
"Last-Translator: Xavier Ordoquy <xordoquy@linovia.com>\n"
"Language-Team: Galician (http://www.transifex.com/projects/p/django-rest-framework/language/gl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: gl\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: authentication.py:70
msgid "Invalid basic header. No credentials provided."
msgstr ""
#: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr ""
#: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr ""
#: authentication.py:97
msgid "Invalid username/password."
msgstr ""
#: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided."
msgstr ""
#: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces."
msgstr ""
#: authentication.py:179
msgid "Invalid token."
msgstr ""
#: authtoken/serializers.py:20
msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr ""
#: exceptions.py:38
msgid "A server error occurred."
msgstr ""
#: exceptions.py:73
msgid "Malformed request."
msgstr ""
#: exceptions.py:78
msgid "Incorrect authentication credentials."
msgstr ""
#: exceptions.py:83
msgid "Authentication credentials were not provided."
msgstr ""
#: exceptions.py:88
msgid "You do not have permission to perform this action."
msgstr ""
#: exceptions.py:93 views.py:78
msgid "Not found."
msgstr ""
#: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed."
msgstr ""
#: exceptions.py:109
msgid "Could not satisfy the request Accept header."
msgstr ""
#: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request."
msgstr ""
#: exceptions.py:134
msgid "Request was throttled."
msgstr ""
#: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:160
msgid "This field is required."
msgstr ""
#: fields.py:163
msgid "This field may not be null."
msgstr ""
#: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean."
msgstr ""
#: fields.py:559
msgid "This field may not be blank."
msgstr ""
#: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters."
msgstr ""
#: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters."
msgstr ""
#: fields.py:598
msgid "Enter a valid email address."
msgstr ""
#: fields.py:609
msgid "This value does not match the required pattern."
msgstr ""
#: fields.py:620
msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens."
msgstr ""
#: fields.py:632
msgid "Enter a valid URL."
msgstr ""
#: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID."
msgstr ""
#: fields.py:679
msgid "A valid integer is required."
msgstr ""
#: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}."
msgstr ""
#: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}."
msgstr ""
#: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large."
msgstr ""
#: fields.py:714 fields.py:747
msgid "A valid number is required."
msgstr ""
#: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr ""
#: fields.py:751
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_decimal_places} decimal places."
msgstr ""
#: fields.py:752
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point."
msgstr ""
#: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:843
msgid "Expected a datetime but got a date."
msgstr ""
#: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:908
msgid "Expected a date but got a datetime."
msgstr ""
#: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice."
msgstr ""
#: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"."
msgstr ""
#: fields.py:1129
msgid "No file was submitted."
msgstr ""
#: fields.py:1130
msgid ""
"The submitted data was not a file. Check the encoding type on the form."
msgstr ""
#: fields.py:1131
msgid "No filename could be determined."
msgstr ""
#: fields.py:1132
msgid "The submitted file is empty."
msgstr ""
#: fields.py:1133
#, python-brace-format
msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})."
msgstr ""
#: fields.py:1175
msgid ""
"Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image."
msgstr ""
#: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr ""
#: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}."
msgstr ""
#: pagination.py:492
msgid "Invalid cursor"
msgstr ""
#: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr ""
#: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr ""
#: relations.py:157
msgid "Invalid hyperlink - No URL match."
msgstr ""
#: relations.py:158
msgid "Invalid hyperlink - Incorrect URL match."
msgstr ""
#: relations.py:159
msgid "Invalid hyperlink - Object does not exist."
msgstr ""
#: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr ""
#: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist."
msgstr ""
#: relations.py:303
msgid "Invalid value."
msgstr ""
#: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22
msgid "This field must be unique."
msgstr ""
#: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set."
msgstr ""
#: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date."
msgstr ""
#: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month."
msgstr ""
#: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year."
msgstr ""
#: versioning.py:39
msgid "Invalid version in \"Accept\" header."
msgstr ""
#: versioning.py:70 versioning.py:112
msgid "Invalid version in URL path."
msgstr ""
#: versioning.py:141
msgid "Invalid version in hostname."
msgstr ""
#: versioning.py:163
msgid "Invalid version in query parameter."
msgstr ""
#: views.py:85
msgid "Permission denied."
msgstr ""
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Django REST framework\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: 2015-06-03 16:30+0000\n"
"Last-Translator: Xavier Ordoquy <xordoquy@linovia.com>\n"
"Language-Team: Galician (Spain) (http://www.transifex.com/projects/p/django-rest-framework/language/gl_ES/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: gl_ES\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: authentication.py:70
msgid "Invalid basic header. No credentials provided."
msgstr ""
#: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr ""
#: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr ""
#: authentication.py:97
msgid "Invalid username/password."
msgstr ""
#: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided."
msgstr ""
#: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces."
msgstr ""
#: authentication.py:179
msgid "Invalid token."
msgstr ""
#: authtoken/serializers.py:20
msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr ""
#: exceptions.py:38
msgid "A server error occurred."
msgstr ""
#: exceptions.py:73
msgid "Malformed request."
msgstr ""
#: exceptions.py:78
msgid "Incorrect authentication credentials."
msgstr ""
#: exceptions.py:83
msgid "Authentication credentials were not provided."
msgstr ""
#: exceptions.py:88
msgid "You do not have permission to perform this action."
msgstr ""
#: exceptions.py:93 views.py:78
msgid "Not found."
msgstr ""
#: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed."
msgstr ""
#: exceptions.py:109
msgid "Could not satisfy the request Accept header."
msgstr ""
#: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request."
msgstr ""
#: exceptions.py:134
msgid "Request was throttled."
msgstr ""
#: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:160
msgid "This field is required."
msgstr ""
#: fields.py:163
msgid "This field may not be null."
msgstr ""
#: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean."
msgstr ""
#: fields.py:559
msgid "This field may not be blank."
msgstr ""
#: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters."
msgstr ""
#: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters."
msgstr ""
#: fields.py:598
msgid "Enter a valid email address."
msgstr ""
#: fields.py:609
msgid "This value does not match the required pattern."
msgstr ""
#: fields.py:620
msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens."
msgstr ""
#: fields.py:632
msgid "Enter a valid URL."
msgstr ""
#: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID."
msgstr ""
#: fields.py:679
msgid "A valid integer is required."
msgstr ""
#: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}."
msgstr ""
#: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}."
msgstr ""
#: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large."
msgstr ""
#: fields.py:714 fields.py:747
msgid "A valid number is required."
msgstr ""
#: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr ""
#: fields.py:751
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_decimal_places} decimal places."
msgstr ""
#: fields.py:752
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point."
msgstr ""
#: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:843
msgid "Expected a datetime but got a date."
msgstr ""
#: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:908
msgid "Expected a date but got a datetime."
msgstr ""
#: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice."
msgstr ""
#: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"."
msgstr ""
#: fields.py:1129
msgid "No file was submitted."
msgstr ""
#: fields.py:1130
msgid ""
"The submitted data was not a file. Check the encoding type on the form."
msgstr ""
#: fields.py:1131
msgid "No filename could be determined."
msgstr ""
#: fields.py:1132
msgid "The submitted file is empty."
msgstr ""
#: fields.py:1133
#, python-brace-format
msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})."
msgstr ""
#: fields.py:1175
msgid ""
"Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image."
msgstr ""
#: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr ""
#: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}."
msgstr ""
#: pagination.py:492
msgid "Invalid cursor"
msgstr ""
#: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr ""
#: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr ""
#: relations.py:157
msgid "Invalid hyperlink - No URL match."
msgstr ""
#: relations.py:158
msgid "Invalid hyperlink - Incorrect URL match."
msgstr ""
#: relations.py:159
msgid "Invalid hyperlink - Object does not exist."
msgstr ""
#: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr ""
#: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist."
msgstr ""
#: relations.py:303
msgid "Invalid value."
msgstr ""
#: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22
msgid "This field must be unique."
msgstr ""
#: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set."
msgstr ""
#: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date."
msgstr ""
#: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month."
msgstr ""
#: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year."
msgstr ""
#: versioning.py:39
msgid "Invalid version in \"Accept\" header."
msgstr ""
#: versioning.py:70 versioning.py:112
msgid "Invalid version in URL path."
msgstr ""
#: versioning.py:141
msgid "Invalid version in hostname."
msgstr ""
#: versioning.py:163
msgid "Invalid version in query parameter."
msgstr ""
#: views.py:85
msgid "Permission denied."
msgstr ""
...@@ -7,9 +7,9 @@ msgid "" ...@@ -7,9 +7,9 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Django REST framework\n" "Project-Id-Version: Django REST framework\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-30 16:23+0000\n" "POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: 2015-01-30 16:27+0000\n" "PO-Revision-Date: 2015-06-03 16:30+0000\n"
"Last-Translator: Thomas Christie <tom@tomchristie.com>\n" "Last-Translator: Xavier Ordoquy <xordoquy@linovia.com>\n"
"Language-Team: Indonesian (http://www.transifex.com/projects/p/django-rest-framework/language/id/)\n" "Language-Team: Indonesian (http://www.transifex.com/projects/p/django-rest-framework/language/id/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
...@@ -17,36 +17,48 @@ msgstr "" ...@@ -17,36 +17,48 @@ msgstr ""
"Language: id\n" "Language: id\n"
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
#: authentication.py:69 #: authentication.py:70
msgid "Invalid basic header. No credentials provided." msgid "Invalid basic header. No credentials provided."
msgstr "" msgstr ""
#: authentication.py:72 #: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces." msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr "" msgstr ""
#: authentication.py:78 #: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded." msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr "" msgstr ""
#: authentication.py:90 #: authentication.py:97
msgid "Invalid username/password." msgid "Invalid username/password."
msgstr "" msgstr ""
#: authentication.py:156 #: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided." msgid "Invalid token header. No credentials provided."
msgstr "" msgstr ""
#: authentication.py:159 #: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces." msgid "Invalid token header. Token string should not contain spaces."
msgstr "" msgstr ""
#: authentication.py:168 #: authentication.py:179
msgid "Invalid token." msgid "Invalid token."
msgstr "" msgstr ""
#: authentication.py:171 #: authtoken/serializers.py:20
msgid "User inactive or deleted." msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr "" msgstr ""
#: exceptions.py:38 #: exceptions.py:38
...@@ -69,11 +81,12 @@ msgstr "" ...@@ -69,11 +81,12 @@ msgstr ""
msgid "You do not have permission to perform this action." msgid "You do not have permission to perform this action."
msgstr "" msgstr ""
#: exceptions.py:93 #: exceptions.py:93 views.py:78
msgid "Not found." msgid "Not found."
msgstr "" msgstr ""
#: exceptions.py:98 #: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed." msgid "Method \"{method}\" not allowed."
msgstr "" msgstr ""
...@@ -82,6 +95,7 @@ msgid "Could not satisfy the request Accept header." ...@@ -82,6 +95,7 @@ msgid "Could not satisfy the request Accept header."
msgstr "" msgstr ""
#: exceptions.py:121 #: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request." msgid "Unsupported media type \"{media_type}\" in request."
msgstr "" msgstr ""
...@@ -89,161 +103,185 @@ msgstr "" ...@@ -89,161 +103,185 @@ msgstr ""
msgid "Request was throttled." msgid "Request was throttled."
msgstr "" msgstr ""
#: fields.py:153 relations.py:132 relations.py:156 validators.py:77 #: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:155 #: validators.py:160
msgid "This field is required." msgid "This field is required."
msgstr "" msgstr ""
#: fields.py:154 #: fields.py:163
msgid "This field may not be null." msgid "This field may not be null."
msgstr "" msgstr ""
#: fields.py:487 fields.py:515 #: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean." msgid "\"{input}\" is not a valid boolean."
msgstr "" msgstr ""
#: fields.py:550 #: fields.py:559
msgid "This field may not be blank." msgid "This field may not be blank."
msgstr "" msgstr ""
#: fields.py:551 fields.py:1324 #: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters." msgid "Ensure this field has no more than {max_length} characters."
msgstr "" msgstr ""
#: fields.py:552 #: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters." msgid "Ensure this field has at least {min_length} characters."
msgstr "" msgstr ""
#: fields.py:587 #: fields.py:598
msgid "Enter a valid email address." msgid "Enter a valid email address."
msgstr "" msgstr ""
#: fields.py:604 #: fields.py:609
msgid "This value does not match the required pattern." msgid "This value does not match the required pattern."
msgstr "" msgstr ""
#: fields.py:615 #: fields.py:620
msgid "" msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or " "Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens." "hyphens."
msgstr "" msgstr ""
#: fields.py:627 #: fields.py:632
msgid "Enter a valid URL." msgid "Enter a valid URL."
msgstr "" msgstr ""
#: fields.py:638 #: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID." msgid "\"{value}\" is not a valid UUID."
msgstr "" msgstr ""
#: fields.py:657 #: fields.py:679
msgid "A valid integer is required." msgid "A valid integer is required."
msgstr "" msgstr ""
#: fields.py:658 fields.py:692 fields.py:725 #: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}." msgid "Ensure this value is less than or equal to {max_value}."
msgstr "" msgstr ""
#: fields.py:659 fields.py:693 fields.py:726 #: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}." msgid "Ensure this value is greater than or equal to {min_value}."
msgstr "" msgstr ""
#: fields.py:660 fields.py:694 fields.py:730 #: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large." msgid "String value too large."
msgstr "" msgstr ""
#: fields.py:691 fields.py:724 #: fields.py:714 fields.py:747
msgid "A valid number is required." msgid "A valid number is required."
msgstr "" msgstr ""
#: fields.py:727 #: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total." msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr "" msgstr ""
#: fields.py:728 #: fields.py:751
#, python-brace-format
msgid "" msgid ""
"Ensure that there are no more than {max_decimal_places} decimal places." "Ensure that there are no more than {max_decimal_places} decimal places."
msgstr "" msgstr ""
#: fields.py:729 #: fields.py:752
#, python-brace-format
msgid "" msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the " "Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point." "decimal point."
msgstr "" msgstr ""
#: fields.py:813 #: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}." msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:814 #: fields.py:843
msgid "Expected a datetime but got a date." msgid "Expected a datetime but got a date."
msgstr "" msgstr ""
#: fields.py:878 #: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}." msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:879 #: fields.py:908
msgid "Expected a date but got a datetime." msgid "Expected a date but got a datetime."
msgstr "" msgstr ""
#: fields.py:936 #: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}." msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:992 fields.py:1036 #: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice." msgid "\"{input}\" is not a valid choice."
msgstr "" msgstr ""
#: fields.py:1037 fields.py:1151 serializers.py:482 #: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"." msgid "Expected a list of items but got type \"{input_type}\"."
msgstr "" msgstr ""
#: fields.py:1067 #: fields.py:1129
msgid "No file was submitted." msgid "No file was submitted."
msgstr "" msgstr ""
#: fields.py:1068 #: fields.py:1130
msgid "" msgid ""
"The submitted data was not a file. Check the encoding type on the form." "The submitted data was not a file. Check the encoding type on the form."
msgstr "" msgstr ""
#: fields.py:1069 #: fields.py:1131
msgid "No filename could be determined." msgid "No filename could be determined."
msgstr "" msgstr ""
#: fields.py:1070 #: fields.py:1132
msgid "The submitted file is empty." msgid "The submitted file is empty."
msgstr "" msgstr ""
#: fields.py:1071 #: fields.py:1133
#, python-brace-format
msgid "" msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})." "Ensure this filename has at most {max_length} characters (it has {length})."
msgstr "" msgstr ""
#: fields.py:1113 #: fields.py:1175
msgid "" msgid ""
"Upload a valid image. The file you uploaded was either not an image or a " "Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image." "corrupted image."
msgstr "" msgstr ""
#: fields.py:1188 #: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"." msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr "" msgstr ""
#: pagination.py:221 #: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}." msgid "Invalid page \"{page_number}\": {message}."
msgstr "" msgstr ""
#: pagination.py:442 #: pagination.py:492
msgid "Invalid cursor" msgid "Invalid cursor"
msgstr "" msgstr ""
#: relations.py:133 #: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist." msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr "" msgstr ""
#: relations.py:134 #: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}." msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr "" msgstr ""
...@@ -260,38 +298,57 @@ msgid "Invalid hyperlink - Object does not exist." ...@@ -260,38 +298,57 @@ msgid "Invalid hyperlink - Object does not exist."
msgstr "" msgstr ""
#: relations.py:160 #: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}." msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr "" msgstr ""
#: relations.py:295 #: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist." msgid "Object with {slug_name}={value} does not exist."
msgstr "" msgstr ""
#: relations.py:296 #: relations.py:303
msgid "Invalid value." msgid "Invalid value."
msgstr "" msgstr ""
#: serializers.py:299 #: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}." msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22 #: validators.py:22
msgid "This field must be unique." msgid "This field must be unique."
msgstr "" msgstr ""
#: validators.py:76 #: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set." msgid "The fields {field_names} must make a unique set."
msgstr "" msgstr ""
#: validators.py:219 #: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date." msgid "This field must be unique for the \"{date_field}\" date."
msgstr "" msgstr ""
#: validators.py:234 #: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month." msgid "This field must be unique for the \"{date_field}\" month."
msgstr "" msgstr ""
#: validators.py:247 #: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year." msgid "This field must be unique for the \"{date_field}\" year."
msgstr "" msgstr ""
...@@ -303,22 +360,14 @@ msgstr "" ...@@ -303,22 +360,14 @@ msgstr ""
msgid "Invalid version in URL path." msgid "Invalid version in URL path."
msgstr "" msgstr ""
#: versioning.py:138 #: versioning.py:141
msgid "Invalid version in hostname." msgid "Invalid version in hostname."
msgstr "" msgstr ""
#: versioning.py:160 #: versioning.py:163
msgid "Invalid version in query parameter." msgid "Invalid version in query parameter."
msgstr "" msgstr ""
#: authtoken/serializers.py:20 #: views.py:85
msgid "User account is disabled." msgid "Permission denied."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr "" msgstr ""
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: Django REST framework\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: 2015-06-03 16:30+0000\n"
"Last-Translator: Xavier Ordoquy <xordoquy@linovia.com>\n"
"Language-Team: Norwegian Bokmål (http://www.transifex.com/projects/p/django-rest-framework/language/nb/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: nb\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: authentication.py:70
msgid "Invalid basic header. No credentials provided."
msgstr ""
#: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr ""
#: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr ""
#: authentication.py:97
msgid "Invalid username/password."
msgstr ""
#: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided."
msgstr ""
#: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces."
msgstr ""
#: authentication.py:179
msgid "Invalid token."
msgstr ""
#: authtoken/serializers.py:20
msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr ""
#: exceptions.py:38
msgid "A server error occurred."
msgstr ""
#: exceptions.py:73
msgid "Malformed request."
msgstr ""
#: exceptions.py:78
msgid "Incorrect authentication credentials."
msgstr ""
#: exceptions.py:83
msgid "Authentication credentials were not provided."
msgstr ""
#: exceptions.py:88
msgid "You do not have permission to perform this action."
msgstr ""
#: exceptions.py:93 views.py:78
msgid "Not found."
msgstr ""
#: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed."
msgstr ""
#: exceptions.py:109
msgid "Could not satisfy the request Accept header."
msgstr ""
#: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request."
msgstr ""
#: exceptions.py:134
msgid "Request was throttled."
msgstr ""
#: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:160
msgid "This field is required."
msgstr ""
#: fields.py:163
msgid "This field may not be null."
msgstr ""
#: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean."
msgstr ""
#: fields.py:559
msgid "This field may not be blank."
msgstr ""
#: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters."
msgstr ""
#: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters."
msgstr ""
#: fields.py:598
msgid "Enter a valid email address."
msgstr ""
#: fields.py:609
msgid "This value does not match the required pattern."
msgstr ""
#: fields.py:620
msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens."
msgstr ""
#: fields.py:632
msgid "Enter a valid URL."
msgstr ""
#: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID."
msgstr ""
#: fields.py:679
msgid "A valid integer is required."
msgstr ""
#: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}."
msgstr ""
#: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}."
msgstr ""
#: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large."
msgstr ""
#: fields.py:714 fields.py:747
msgid "A valid number is required."
msgstr ""
#: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr ""
#: fields.py:751
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_decimal_places} decimal places."
msgstr ""
#: fields.py:752
#, python-brace-format
msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point."
msgstr ""
#: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:843
msgid "Expected a datetime but got a date."
msgstr ""
#: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:908
msgid "Expected a date but got a datetime."
msgstr ""
#: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice."
msgstr ""
#: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"."
msgstr ""
#: fields.py:1129
msgid "No file was submitted."
msgstr ""
#: fields.py:1130
msgid ""
"The submitted data was not a file. Check the encoding type on the form."
msgstr ""
#: fields.py:1131
msgid "No filename could be determined."
msgstr ""
#: fields.py:1132
msgid "The submitted file is empty."
msgstr ""
#: fields.py:1133
#, python-brace-format
msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})."
msgstr ""
#: fields.py:1175
msgid ""
"Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image."
msgstr ""
#: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr ""
#: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}."
msgstr ""
#: pagination.py:492
msgid "Invalid cursor"
msgstr ""
#: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr ""
#: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr ""
#: relations.py:157
msgid "Invalid hyperlink - No URL match."
msgstr ""
#: relations.py:158
msgid "Invalid hyperlink - Incorrect URL match."
msgstr ""
#: relations.py:159
msgid "Invalid hyperlink - Object does not exist."
msgstr ""
#: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr ""
#: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist."
msgstr ""
#: relations.py:303
msgid "Invalid value."
msgstr ""
#: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22
msgid "This field must be unique."
msgstr ""
#: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set."
msgstr ""
#: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date."
msgstr ""
#: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month."
msgstr ""
#: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year."
msgstr ""
#: versioning.py:39
msgid "Invalid version in \"Accept\" header."
msgstr ""
#: versioning.py:70 versioning.py:112
msgid "Invalid version in URL path."
msgstr ""
#: versioning.py:141
msgid "Invalid version in hostname."
msgstr ""
#: versioning.py:163
msgid "Invalid version in query parameter."
msgstr ""
#: views.py:85
msgid "Permission denied."
msgstr ""
...@@ -7,9 +7,9 @@ msgid "" ...@@ -7,9 +7,9 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Django REST framework\n" "Project-Id-Version: Django REST framework\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-30 16:23+0000\n" "POT-Creation-Date: 2015-06-03 17:30+0100\n"
"PO-Revision-Date: 2015-01-30 16:27+0000\n" "PO-Revision-Date: 2015-06-03 16:30+0000\n"
"Last-Translator: Thomas Christie <tom@tomchristie.com>\n" "Last-Translator: Xavier Ordoquy <xordoquy@linovia.com>\n"
"Language-Team: Dutch (http://www.transifex.com/projects/p/django-rest-framework/language/nl/)\n" "Language-Team: Dutch (http://www.transifex.com/projects/p/django-rest-framework/language/nl/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
...@@ -17,36 +17,48 @@ msgstr "" ...@@ -17,36 +17,48 @@ msgstr ""
"Language: nl\n" "Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: authentication.py:69 #: authentication.py:70
msgid "Invalid basic header. No credentials provided." msgid "Invalid basic header. No credentials provided."
msgstr "" msgstr ""
#: authentication.py:72 #: authentication.py:73
msgid "Invalid basic header. Credentials string should not contain spaces." msgid "Invalid basic header. Credentials string should not contain spaces."
msgstr "" msgstr ""
#: authentication.py:78 #: authentication.py:79
msgid "Invalid basic header. Credentials not correctly base64 encoded." msgid "Invalid basic header. Credentials not correctly base64 encoded."
msgstr "" msgstr ""
#: authentication.py:90 #: authentication.py:97
msgid "Invalid username/password." msgid "Invalid username/password."
msgstr "" msgstr ""
#: authentication.py:156 #: authentication.py:100 authentication.py:182
msgid "User inactive or deleted."
msgstr ""
#: authentication.py:167
msgid "Invalid token header. No credentials provided." msgid "Invalid token header. No credentials provided."
msgstr "" msgstr ""
#: authentication.py:159 #: authentication.py:170
msgid "Invalid token header. Token string should not contain spaces." msgid "Invalid token header. Token string should not contain spaces."
msgstr "" msgstr ""
#: authentication.py:168 #: authentication.py:179
msgid "Invalid token." msgid "Invalid token."
msgstr "" msgstr ""
#: authentication.py:171 #: authtoken/serializers.py:20
msgid "User inactive or deleted." msgid "User account is disabled."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr "" msgstr ""
#: exceptions.py:38 #: exceptions.py:38
...@@ -69,11 +81,12 @@ msgstr "" ...@@ -69,11 +81,12 @@ msgstr ""
msgid "You do not have permission to perform this action." msgid "You do not have permission to perform this action."
msgstr "" msgstr ""
#: exceptions.py:93 #: exceptions.py:93 views.py:78
msgid "Not found." msgid "Not found."
msgstr "" msgstr ""
#: exceptions.py:98 #: exceptions.py:98
#, python-brace-format
msgid "Method \"{method}\" not allowed." msgid "Method \"{method}\" not allowed."
msgstr "" msgstr ""
...@@ -82,6 +95,7 @@ msgid "Could not satisfy the request Accept header." ...@@ -82,6 +95,7 @@ msgid "Could not satisfy the request Accept header."
msgstr "" msgstr ""
#: exceptions.py:121 #: exceptions.py:121
#, python-brace-format
msgid "Unsupported media type \"{media_type}\" in request." msgid "Unsupported media type \"{media_type}\" in request."
msgstr "" msgstr ""
...@@ -89,161 +103,185 @@ msgstr "" ...@@ -89,161 +103,185 @@ msgstr ""
msgid "Request was throttled." msgid "Request was throttled."
msgstr "" msgstr ""
#: fields.py:153 relations.py:132 relations.py:156 validators.py:77 #: fields.py:162 relations.py:132 relations.py:156 validators.py:77
#: validators.py:155 #: validators.py:160
msgid "This field is required." msgid "This field is required."
msgstr "" msgstr ""
#: fields.py:154 #: fields.py:163
msgid "This field may not be null." msgid "This field may not be null."
msgstr "" msgstr ""
#: fields.py:487 fields.py:515 #: fields.py:496 fields.py:524
#, python-brace-format
msgid "\"{input}\" is not a valid boolean." msgid "\"{input}\" is not a valid boolean."
msgstr "" msgstr ""
#: fields.py:550 #: fields.py:559
msgid "This field may not be blank." msgid "This field may not be blank."
msgstr "" msgstr ""
#: fields.py:551 fields.py:1324 #: fields.py:560 fields.py:1386
#, python-brace-format
msgid "Ensure this field has no more than {max_length} characters." msgid "Ensure this field has no more than {max_length} characters."
msgstr "" msgstr ""
#: fields.py:552 #: fields.py:561
#, python-brace-format
msgid "Ensure this field has at least {min_length} characters." msgid "Ensure this field has at least {min_length} characters."
msgstr "" msgstr ""
#: fields.py:587 #: fields.py:598
msgid "Enter a valid email address." msgid "Enter a valid email address."
msgstr "" msgstr ""
#: fields.py:604 #: fields.py:609
msgid "This value does not match the required pattern." msgid "This value does not match the required pattern."
msgstr "" msgstr ""
#: fields.py:615 #: fields.py:620
msgid "" msgid ""
"Enter a valid \"slug\" consisting of letters, numbers, underscores or " "Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens." "hyphens."
msgstr "" msgstr ""
#: fields.py:627 #: fields.py:632
msgid "Enter a valid URL." msgid "Enter a valid URL."
msgstr "" msgstr ""
#: fields.py:638 #: fields.py:645
#, python-brace-format
msgid "\"{value}\" is not a valid UUID." msgid "\"{value}\" is not a valid UUID."
msgstr "" msgstr ""
#: fields.py:657 #: fields.py:679
msgid "A valid integer is required." msgid "A valid integer is required."
msgstr "" msgstr ""
#: fields.py:658 fields.py:692 fields.py:725 #: fields.py:680 fields.py:715 fields.py:748
#, python-brace-format
msgid "Ensure this value is less than or equal to {max_value}." msgid "Ensure this value is less than or equal to {max_value}."
msgstr "" msgstr ""
#: fields.py:659 fields.py:693 fields.py:726 #: fields.py:681 fields.py:716 fields.py:749
#, python-brace-format
msgid "Ensure this value is greater than or equal to {min_value}." msgid "Ensure this value is greater than or equal to {min_value}."
msgstr "" msgstr ""
#: fields.py:660 fields.py:694 fields.py:730 #: fields.py:682 fields.py:717 fields.py:753
msgid "String value too large." msgid "String value too large."
msgstr "" msgstr ""
#: fields.py:691 fields.py:724 #: fields.py:714 fields.py:747
msgid "A valid number is required." msgid "A valid number is required."
msgstr "" msgstr ""
#: fields.py:727 #: fields.py:750
#, python-brace-format
msgid "Ensure that there are no more than {max_digits} digits in total." msgid "Ensure that there are no more than {max_digits} digits in total."
msgstr "" msgstr ""
#: fields.py:728 #: fields.py:751
#, python-brace-format
msgid "" msgid ""
"Ensure that there are no more than {max_decimal_places} decimal places." "Ensure that there are no more than {max_decimal_places} decimal places."
msgstr "" msgstr ""
#: fields.py:729 #: fields.py:752
#, python-brace-format
msgid "" msgid ""
"Ensure that there are no more than {max_whole_digits} digits before the " "Ensure that there are no more than {max_whole_digits} digits before the "
"decimal point." "decimal point."
msgstr "" msgstr ""
#: fields.py:813 #: fields.py:842
#, python-brace-format
msgid "Datetime has wrong format. Use one of these formats instead: {format}." msgid "Datetime has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:814 #: fields.py:843
msgid "Expected a datetime but got a date." msgid "Expected a datetime but got a date."
msgstr "" msgstr ""
#: fields.py:878 #: fields.py:907
#, python-brace-format
msgid "Date has wrong format. Use one of these formats instead: {format}." msgid "Date has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:879 #: fields.py:908
msgid "Expected a date but got a datetime." msgid "Expected a date but got a datetime."
msgstr "" msgstr ""
#: fields.py:936 #: fields.py:971
#, python-brace-format
msgid "Time has wrong format. Use one of these formats instead: {format}." msgid "Time has wrong format. Use one of these formats instead: {format}."
msgstr "" msgstr ""
#: fields.py:992 fields.py:1036 #: fields.py:1025
#, python-brace-format
msgid "Duration has wrong format. Use one of these formats instead: {format}."
msgstr ""
#: fields.py:1050 fields.py:1094
#, python-brace-format
msgid "\"{input}\" is not a valid choice." msgid "\"{input}\" is not a valid choice."
msgstr "" msgstr ""
#: fields.py:1037 fields.py:1151 serializers.py:482 #: fields.py:1095 fields.py:1213 serializers.py:487
#, python-brace-format
msgid "Expected a list of items but got type \"{input_type}\"." msgid "Expected a list of items but got type \"{input_type}\"."
msgstr "" msgstr ""
#: fields.py:1067 #: fields.py:1129
msgid "No file was submitted." msgid "No file was submitted."
msgstr "" msgstr ""
#: fields.py:1068 #: fields.py:1130
msgid "" msgid ""
"The submitted data was not a file. Check the encoding type on the form." "The submitted data was not a file. Check the encoding type on the form."
msgstr "" msgstr ""
#: fields.py:1069 #: fields.py:1131
msgid "No filename could be determined." msgid "No filename could be determined."
msgstr "" msgstr ""
#: fields.py:1070 #: fields.py:1132
msgid "The submitted file is empty." msgid "The submitted file is empty."
msgstr "" msgstr ""
#: fields.py:1071 #: fields.py:1133
#, python-brace-format
msgid "" msgid ""
"Ensure this filename has at most {max_length} characters (it has {length})." "Ensure this filename has at most {max_length} characters (it has {length})."
msgstr "" msgstr ""
#: fields.py:1113 #: fields.py:1175
msgid "" msgid ""
"Upload a valid image. The file you uploaded was either not an image or a " "Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image." "corrupted image."
msgstr "" msgstr ""
#: fields.py:1188 #: fields.py:1250
#, python-brace-format
msgid "Expected a dictionary of items but got type \"{input_type}\"." msgid "Expected a dictionary of items but got type \"{input_type}\"."
msgstr "" msgstr ""
#: pagination.py:221 #: pagination.py:231
#, python-brace-format
msgid "Invalid page \"{page_number}\": {message}." msgid "Invalid page \"{page_number}\": {message}."
msgstr "" msgstr ""
#: pagination.py:442 #: pagination.py:492
msgid "Invalid cursor" msgid "Invalid cursor"
msgstr "" msgstr ""
#: relations.py:133 #: relations.py:133
#, python-brace-format
msgid "Invalid pk \"{pk_value}\" - object does not exist." msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr "" msgstr ""
#: relations.py:134 #: relations.py:134
#, python-brace-format
msgid "Incorrect type. Expected pk value, received {data_type}." msgid "Incorrect type. Expected pk value, received {data_type}."
msgstr "" msgstr ""
...@@ -260,38 +298,57 @@ msgid "Invalid hyperlink - Object does not exist." ...@@ -260,38 +298,57 @@ msgid "Invalid hyperlink - Object does not exist."
msgstr "" msgstr ""
#: relations.py:160 #: relations.py:160
#, python-brace-format
msgid "Incorrect type. Expected URL string, received {data_type}." msgid "Incorrect type. Expected URL string, received {data_type}."
msgstr "" msgstr ""
#: relations.py:295 #: relations.py:302
#, python-brace-format
msgid "Object with {slug_name}={value} does not exist." msgid "Object with {slug_name}={value} does not exist."
msgstr "" msgstr ""
#: relations.py:296 #: relations.py:303
msgid "Invalid value." msgid "Invalid value."
msgstr "" msgstr ""
#: serializers.py:299 #: serializers.py:304
#, python-brace-format
msgid "Invalid data. Expected a dictionary, but got {datatype}." msgid "Invalid data. Expected a dictionary, but got {datatype}."
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 ""
#: 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 ""
#: validators.py:22 #: validators.py:22
msgid "This field must be unique." msgid "This field must be unique."
msgstr "" msgstr ""
#: validators.py:76 #: validators.py:76
#, python-brace-format
msgid "The fields {field_names} must make a unique set." msgid "The fields {field_names} must make a unique set."
msgstr "" msgstr ""
#: validators.py:219 #: validators.py:224
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" date." msgid "This field must be unique for the \"{date_field}\" date."
msgstr "" msgstr ""
#: validators.py:234 #: validators.py:239
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" month." msgid "This field must be unique for the \"{date_field}\" month."
msgstr "" msgstr ""
#: validators.py:247 #: validators.py:252
#, python-brace-format
msgid "This field must be unique for the \"{date_field}\" year." msgid "This field must be unique for the \"{date_field}\" year."
msgstr "" msgstr ""
...@@ -303,22 +360,14 @@ msgstr "" ...@@ -303,22 +360,14 @@ msgstr ""
msgid "Invalid version in URL path." msgid "Invalid version in URL path."
msgstr "" msgstr ""
#: versioning.py:138 #: versioning.py:141
msgid "Invalid version in hostname." msgid "Invalid version in hostname."
msgstr "" msgstr ""
#: versioning.py:160 #: versioning.py:163
msgid "Invalid version in query parameter." msgid "Invalid version in query parameter."
msgstr "" msgstr ""
#: authtoken/serializers.py:20 #: views.py:85
msgid "User account is disabled." msgid "Permission denied."
msgstr ""
#: authtoken/serializers.py:23
msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\"."
msgstr "" msgstr ""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment