mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 16:24:18 +03:00
Merge remote-tracking branch 'reference/master' into feature/improve_schema_shortcut
* reference/master: (22 commits) Clarify get_schema_fields signature Updated monthly report link on funding page Bumped django-guardian version. remove django 1.11 from allow_failure matrix update django 1.11 to stable release in tox Update existing vary headers in response instead of overwriting them. Update links after moving to encode org Use overridden settings exception handler Pass initkwargs stored on view to instance Update 7-schemas-and-client-libraries.md Update Boolean field to more closely match python library Fix parser names in docstring. Fix typo at docstring update test case update test case fix unique=True validation for ChoiceField Added drfpasswordless to Authentication docs Document adding django_filters to installed apps Added drfpasswordless to third party packages topic page. Added drfpasswordless to authentication topic page. ...
This commit is contained in:
commit
d757127e9a
|
@ -35,7 +35,6 @@ matrix:
|
|||
|
||||
allow_failures:
|
||||
- env: DJANGO=master
|
||||
- env: DJANGO=1.11
|
||||
|
||||
install:
|
||||
- pip install tox tox-travis
|
||||
|
|
|
@ -50,7 +50,7 @@ Getting involved in triaging incoming issues is a good way to start contributing
|
|||
|
||||
To start developing on Django REST framework, clone the repo:
|
||||
|
||||
git clone git@github.com:tomchristie/django-rest-framework.git
|
||||
git clone git@github.com:encode/django-rest-framework.git
|
||||
|
||||
Changes should broadly follow the [PEP 8][pep-8] style conventions, and we recommend you set up your editor to automatically indicate non-conforming styles.
|
||||
|
||||
|
@ -198,10 +198,10 @@ If you want to draw attention to a note or warning, use a pair of enclosing line
|
|||
[code-of-conduct]: https://www.djangoproject.com/conduct/
|
||||
[google-group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
|
||||
[so-filter]: http://stackexchange.com/filters/66475/rest-framework
|
||||
[issues]: https://github.com/tomchristie/django-rest-framework/issues?state=open
|
||||
[issues]: https://github.com/encode/django-rest-framework/issues?state=open
|
||||
[pep-8]: http://www.python.org/dev/peps/pep-0008/
|
||||
[pull-requests]: https://help.github.com/articles/using-pull-requests
|
||||
[tox]: https://tox.readthedocs.io/en/latest/
|
||||
[markdown]: http://daringfireball.net/projects/markdown/basics
|
||||
[docs]: https://github.com/tomchristie/django-rest-framework/tree/master/docs
|
||||
[docs]: https://github.com/encode/django-rest-framework/tree/master/docs
|
||||
[mou]: http://mouapp.com/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
*Note*: Before submitting this pull request, please review our [contributing guidelines](https://github.com/tomchristie/django-rest-framework/blob/master/CONTRIBUTING.md#pull-requests).
|
||||
*Note*: Before submitting this pull request, please review our [contributing guidelines](https://github.com/encode/django-rest-framework/blob/master/CONTRIBUTING.md#pull-requests).
|
||||
|
||||
## Description
|
||||
|
||||
|
|
20
README.md
20
README.md
|
@ -21,12 +21,12 @@ The initial aim is to provide a single full-time position on REST framework.
|
|||
*Every single sign-up makes a significant impact towards making that possible.*
|
||||
|
||||
<p align="center">
|
||||
<a href="http://jobs.rover.com/"><img src="https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/docs/img/premium/rover-readme.png"/></a>
|
||||
<a href="https://getsentry.com/welcome/"><img src="https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/docs/img/premium/sentry-readme.png"/></a>
|
||||
<a href="https://getstream.io/try-the-api/?utm_source=drf&utm_medium=banner&utm_campaign=drf"><img src="https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/docs/img/premium/stream-readme.png"/></a>
|
||||
<a href="https://hello.machinalis.co.uk/"><img src="https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/docs/img/premium/machinalis-readme.png"/></a>
|
||||
<a href="https://rollbar.com/"><img src="https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/docs/img/premium/rollbar-readme.png"/></a>
|
||||
<a href="https://micropyramid.com/django-rest-framework-development-services/"><img src="https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/docs/img/premium/micropyramid-readme.png"/></a>
|
||||
<a href="http://jobs.rover.com/"><img src="https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/rover-readme.png"/></a>
|
||||
<a href="https://getsentry.com/welcome/"><img src="https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/sentry-readme.png"/></a>
|
||||
<a href="https://getstream.io/try-the-api/?utm_source=drf&utm_medium=banner&utm_campaign=drf"><img src="https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/stream-readme.png"/></a>
|
||||
<a href="https://hello.machinalis.co.uk/"><img src="https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/machinalis-readme.png"/></a>
|
||||
<a href="https://rollbar.com/"><img src="https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/rollbar-readme.png"/></a>
|
||||
<a href="https://micropyramid.com/django-rest-framework-development-services/"><img src="https://raw.githubusercontent.com/encode/django-rest-framework/master/docs/img/premium/micropyramid-readme.png"/></a>
|
||||
</p>
|
||||
|
||||
*Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Rover](http://jobs.rover.com/), [Sentry](https://getsentry.com/welcome/), [Stream](https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf), [Machinalis](https://hello.machinalis.co.uk/), [Rollbar](https://rollbar.com), and [MicroPyramid](https://micropyramid.com/django-rest-framework-development-services/).*
|
||||
|
@ -176,10 +176,10 @@ If you believe you've found something in Django REST framework which has securit
|
|||
|
||||
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.
|
||||
|
||||
[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
|
||||
[coverage-status-image]: https://img.shields.io/codecov/c/github/tomchristie/django-rest-framework/master.svg
|
||||
[codecov]: http://codecov.io/github/tomchristie/django-rest-framework?branch=master
|
||||
[build-status-image]: https://secure.travis-ci.org/encode/django-rest-framework.svg?branch=master
|
||||
[travis]: http://travis-ci.org/encode/django-rest-framework?branch=master
|
||||
[coverage-status-image]: https://img.shields.io/codecov/c/github/encode/django-rest-framework/master.svg
|
||||
[codecov]: http://codecov.io/github/encode/django-rest-framework?branch=master
|
||||
[pypi-version]: https://img.shields.io/pypi/v/djangorestframework.svg
|
||||
[pypi]: https://pypi.python.org/pypi/djangorestframework
|
||||
[twitter]: https://twitter.com/_tomchristie
|
||||
|
|
|
@ -356,6 +356,10 @@ HTTP Signature (currently a [IETF draft][http-signature-ietf-draft]) provides a
|
|||
|
||||
[Django-rest-knox][django-rest-knox] library provides models and views to handle token based authentication in a more secure and extensible way than the built-in TokenAuthentication scheme - with Single Page Applications and Mobile clients in mind. It provides per-client tokens, and views to generate them when provided some other authentication (usually basic authentication), to delete the token (providing a server enforced logout) and to delete all tokens (logs out all clients that a user is logged into).
|
||||
|
||||
## drfpasswordless
|
||||
|
||||
[drfpasswordless][drfpasswordless] adds (Medium, Square Cash inspired) passwordless support to Django REST Framework's own TokenAuthentication scheme. Users log in and sign up with a token sent to a contact point like an email address or a mobile number.
|
||||
|
||||
[cite]: http://jacobian.org/writing/rest-worst-practices/
|
||||
[http401]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2
|
||||
[http403]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4
|
||||
|
@ -396,3 +400,4 @@ HTTP Signature (currently a [IETF draft][http-signature-ietf-draft]) provides a
|
|||
[django-rest-auth]: https://github.com/Tivix/django-rest-auth
|
||||
[django-rest-framework-social-oauth2]: https://github.com/PhilipGarnero/django-rest-framework-social-oauth2
|
||||
[django-rest-knox]: https://github.com/James1345/django-rest-knox
|
||||
[drfpasswordless]: https://github.com/aaronn/django-rest-framework-passwordless
|
||||
|
|
|
@ -142,7 +142,7 @@ Note that you can use both an overridden `.get_queryset()` and generic filtering
|
|||
The `django-filter` library includes a `DjangoFilterBackend` class which
|
||||
supports highly customizable field filtering for REST framework.
|
||||
|
||||
To use `DjangoFilterBackend`, first install `django-filter`.
|
||||
To use `DjangoFilterBackend`, first install `django-filter`. Then add `django_filters` to Django's `INSTALLED_APPS`
|
||||
|
||||
pip install django-filter
|
||||
|
||||
|
@ -432,8 +432,11 @@ The method should return a rendered HTML string.
|
|||
## Pagination & schemas
|
||||
|
||||
You can also make the filter controls available to the schema autogeneration
|
||||
that REST framework provides, by implementing a `get_schema_fields()` method,
|
||||
which should return a list of `coreapi.Field` instances.
|
||||
that REST framework provides, by implementing a `get_schema_fields()` method. This method should have the following signature:
|
||||
|
||||
`get_schema_fields(self, view)`
|
||||
|
||||
The method should return a list of `coreapi.Field` instances.
|
||||
|
||||
# Third party packages
|
||||
|
||||
|
|
|
@ -279,8 +279,11 @@ API responses for list endpoints will now include a `Link` header, instead of in
|
|||
## Pagination & schemas
|
||||
|
||||
You can also make the pagination controls available to the schema autogeneration
|
||||
that REST framework provides, by implementing a `get_schema_fields()` method,
|
||||
which should return a list of `coreapi.Field` instances.
|
||||
that REST framework provides, by implementing a `get_schema_fields()` method. This method should have the following signature:
|
||||
|
||||
`get_schema_fields(self, view)`
|
||||
|
||||
The method should return a list of `coreapi.Field` instances.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
</style>
|
||||
|
||||
<p class="badges" height=20px>
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=tomchristie&repo=django-rest-framework&type=watch&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=encode&repo=django-rest-framework&type=watch&count=true" class="github-star-button" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
|
||||
|
||||
<a href="http://travis-ci.org/tomchristie/django-rest-framework?branch=master">
|
||||
<img src="https://secure.travis-ci.org/tomchristie/django-rest-framework.svg?branch=master" class="status-badge">
|
||||
<a href="http://travis-ci.org/encode/django-rest-framework?branch=master">
|
||||
<img src="https://secure.travis-ci.org/encode/django-rest-framework.svg?branch=master" class="status-badge">
|
||||
</a>
|
||||
|
||||
<a href="https://pypi.python.org/pypi/djangorestframework">
|
||||
|
@ -108,7 +108,7 @@ Install using `pip`, including any optional packages you want...
|
|||
|
||||
...or clone the project from github.
|
||||
|
||||
git clone git@github.com:tomchristie/django-rest-framework.git
|
||||
git clone git@github.com:encode/django-rest-framework.git
|
||||
|
||||
Add `'rest_framework'` to your `INSTALLED_APPS` setting.
|
||||
|
||||
|
@ -310,8 +310,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
[markdown]: http://pypi.python.org/pypi/Markdown/
|
||||
[django-filter]: http://pypi.python.org/pypi/django-filter
|
||||
[django-crispy-forms]: https://github.com/maraujop/django-crispy-forms
|
||||
[django-guardian]: https://github.com/lukaszb/django-guardian
|
||||
[0.4]: https://github.com/tomchristie/django-rest-framework/tree/0.4.X
|
||||
[django-guardian]: https://github.com/django-guardian/django-guardian
|
||||
[0.4]: https://github.com/encode/django-rest-framework/tree/0.4.X
|
||||
[image]: img/quickstart.png
|
||||
[index]: .
|
||||
[oauth1-section]: api-guide/authentication/#django-rest-framework-oauth
|
||||
|
|
|
@ -155,5 +155,5 @@ From version 2.2 onwards, serializers with hyperlinked relationships *always* re
|
|||
[mailing-list]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
|
||||
[django-rest-framework-docs]: https://github.com/marcgibbons/django-rest-framework-docs
|
||||
[marcgibbons]: https://github.com/marcgibbons/
|
||||
[issues]: https://github.com/tomchristie/django-rest-framework/issues
|
||||
[564]: https://github.com/tomchristie/django-rest-framework/issues/564
|
||||
[issues]: https://github.com/encode/django-rest-framework/issues
|
||||
[564]: https://github.com/encode/django-rest-framework/issues/564
|
||||
|
|
|
@ -167,6 +167,6 @@ Once again, many thanks to all the generous [backers and sponsors][kickstarter-s
|
|||
[view-name-and-description-settings]: ../api-guide/settings#view-names-and-descriptions
|
||||
[client-ip-identification]: ../api-guide/throttling#how-clients-are-identified
|
||||
[2-3-announcement]: 2.3-announcement
|
||||
[github-labels]: https://github.com/tomchristie/django-rest-framework/issues
|
||||
[github-milestones]: https://github.com/tomchristie/django-rest-framework/milestones
|
||||
[github-labels]: https://github.com/encode/django-rest-framework/issues
|
||||
[github-milestones]: https://github.com/encode/django-rest-framework/milestones
|
||||
[kickstarter-sponsors]: kickstarter-announcement#sponsors
|
||||
|
|
|
@ -957,9 +957,9 @@ The 3.1 release is planned to address improvements in the following components:
|
|||
|
||||
The 3.2 release is planned to introduce an alternative admin-style interface to the browsable API.
|
||||
|
||||
You can follow development on the GitHub site, where we use [milestones to indicate planning timescales](https://github.com/tomchristie/django-rest-framework/milestones).
|
||||
You can follow development on the GitHub site, where we use [milestones to indicate planning timescales](https://github.com/encode/django-rest-framework/milestones).
|
||||
|
||||
[kickstarter]: http://kickstarter.com/projects/tomchristie/django-rest-framework-3
|
||||
[sponsors]: http://www.django-rest-framework.org/topics/kickstarter-announcement/#sponsors
|
||||
[mixins.py]: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/mixins.py
|
||||
[mixins.py]: https://github.com/encode/django-rest-framework/blob/master/rest_framework/mixins.py
|
||||
[django-localization]: https://docs.djangoproject.com/en/stable/topics/i18n/translation/#localization-how-to-create-language-files
|
||||
|
|
|
@ -8,7 +8,7 @@ This interface is intended to act as a more user-friendly interface to the API.
|
|||
|
||||
We've also fixed a huge number of issues, and made numerous cleanups and improvements.
|
||||
|
||||
Over the course of the 3.1.x series we've [resolved nearly 600 tickets](https://github.com/tomchristie/django-rest-framework/issues?utf8=%E2%9C%93&q=closed%3A%3E2015-03-05) on our GitHub issue tracker. This means we're currently running at a rate of **closing around 100 issues or pull requests per month**.
|
||||
Over the course of the 3.1.x series we've [resolved nearly 600 tickets](https://github.com/encode/django-rest-framework/issues?utf8=%E2%9C%93&q=closed%3A%3E2015-03-05) on our GitHub issue tracker. This means we're currently running at a rate of **closing around 100 issues or pull requests per month**.
|
||||
|
||||
None of this would have been possible without the support of our wonderful Kickstarter backers. If you're looking for a job in Django development we'd strongly recommend taking [a look through our sponsors](http://www.django-rest-framework.org/topics/kickstarter-announcement/#sponsors) and finding out who's hiring.
|
||||
|
||||
|
|
|
@ -53,6 +53,6 @@ The following pagination view attributes and settings have been moved into attri
|
|||
The `ModelSerializer` and `HyperlinkedModelSerializer` classes should now include either a `fields` or `exclude` option, although the `fields = '__all__'` shortcut may be used. Failing to include either of these two options is currently pending deprecation, and will be removed entirely in the 3.5 release. This behavior brings `ModelSerializer` more closely in line with Django's `ModelForm` behavior.
|
||||
|
||||
[forms-api]: html-and-forms.md
|
||||
[ajax-form]: https://github.com/tomchristie/ajax-form
|
||||
[ajax-form]: https://github.com/encode/ajax-form
|
||||
[jsonfield]: ../../api-guide/fields#jsonfield
|
||||
[django-supported-versions]: https://www.djangoproject.com/download/#supported-versions
|
|
@ -188,7 +188,7 @@ The full set of itemized release notes [are available here][release-notes].
|
|||
[tut-7]: ../../tutorial/7-schemas-and-client-libraries/
|
||||
[schema-generation]: ../../api-guide/schemas/
|
||||
[api-clients]: api-clients.md
|
||||
[milestone]: https://github.com/tomchristie/django-rest-framework/milestone/35
|
||||
[milestone]: https://github.com/encode/django-rest-framework/milestone/35
|
||||
[release-notes]: release-notes#34
|
||||
[metadata]: ../../api-guide/metadata/#custom-metadata-classes
|
||||
[gh3751]: https://github.com/tomchristie/django-rest-framework/issues/3751
|
||||
[gh3751]: https://github.com/encode/django-rest-framework/issues/3751
|
||||
|
|
|
@ -261,6 +261,6 @@ in version 3.3 and raised a deprecation warning in 3.4. Its usage is now mandato
|
|||
[schema-generation-api]: ../api-guide/schemas/#schemagenerator
|
||||
[schema-docs]: ../api-guide/schemas/#schemas-as-documentation
|
||||
[schema-view]: ../api-guide/schemas/#the-get_schema_view-shortcut
|
||||
[django-rest-raml]: https://github.com/tomchristie/django-rest-raml
|
||||
[django-rest-raml]: https://github.com/encode/django-rest-raml
|
||||
[raml-image]: ../img/raml.png
|
||||
[raml-codec]: https://github.com/core-api/python-raml-codec
|
||||
|
|
|
@ -81,7 +81,7 @@ was later [dropped from the spec][html5]. There remains
|
|||
as well as how to support content types other than form-encoded data.
|
||||
|
||||
[cite]: http://www.amazon.com/Restful-Web-Services-Leonard-Richardson/dp/0596529260
|
||||
[ajax-form]: https://github.com/tomchristie/ajax-form
|
||||
[ajax-form]: https://github.com/encode/ajax-form
|
||||
[rails]: http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work
|
||||
[html5]: http://www.w3.org/TR/html5-diff/#changes-2010-06-24
|
||||
[put_delete]: http://amundsen.com/examples/put-delete-forms/
|
||||
|
|
|
@ -50,7 +50,7 @@ Getting involved in triaging incoming issues is a good way to start contributing
|
|||
|
||||
To start developing on Django REST framework, clone the repo:
|
||||
|
||||
git clone git@github.com:tomchristie/django-rest-framework.git
|
||||
git clone git@github.com:encode/django-rest-framework.git
|
||||
|
||||
Changes should broadly follow the [PEP 8][pep-8] style conventions, and we recommend you set up your editor to automatically indicate non-conforming styles.
|
||||
|
||||
|
@ -202,11 +202,11 @@ If you want to draw attention to a note or warning, use a pair of enclosing line
|
|||
[code-of-conduct]: https://www.djangoproject.com/conduct/
|
||||
[google-group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
|
||||
[so-filter]: http://stackexchange.com/filters/66475/rest-framework
|
||||
[issues]: https://github.com/tomchristie/django-rest-framework/issues?state=open
|
||||
[issues]: https://github.com/encode/django-rest-framework/issues?state=open
|
||||
[pep-8]: http://www.python.org/dev/peps/pep-0008/
|
||||
[travis-status]: ../img/travis-status.png
|
||||
[pull-requests]: https://help.github.com/articles/using-pull-requests
|
||||
[tox]: https://tox.readthedocs.io/en/latest/
|
||||
[markdown]: http://daringfireball.net/projects/markdown/basics
|
||||
[docs]: https://github.com/tomchristie/django-rest-framework/tree/master/docs
|
||||
[docs]: https://github.com/encode/django-rest-framework/tree/master/docs
|
||||
[mou]: http://mouapp.com/
|
||||
|
|
|
@ -140,10 +140,14 @@ Sign up for a paid plan today, and help ensure that REST framework becomes a sus
|
|||
>
|
||||
> — José Padilla, Django REST framework contributor
|
||||
|
||||
|
||||
|
||||
> The number one feature of the Python programming language is its community. Such a community is only possible because of the Open Source nature of the language and all the culture that comes from it. Building great Open Source projects require great minds. Given that, we at Vinta are not only proud to sponsor the team behind DRF but we also recognize the ROI that comes from it.
|
||||
>
|
||||
> — Filipe Ximenes, Vinta Software
|
||||
|
||||
|
||||
|
||||
> It's really awesome that this project continues to endure. The code base is top notch and the maintainers are committed to the highest level of quality.
|
||||
DRF is one of the core reasons why Django is top choice among web frameworks today. In my opinion, it sets the standard for rest frameworks for the development community at large.
|
||||
>
|
||||
|
@ -325,7 +329,7 @@ For further enquires please contact <a href=mailto:funding@django-rest-framework
|
|||
|
||||
## Accountability
|
||||
|
||||
In an effort to keep the project as transparent as possible, we are releasing [monthly progress reports](http://www.encode.io/reports/february-2017) and regularly include financial reports and cost breakdowns.
|
||||
In an effort to keep the project as transparent as possible, we are releasing [monthly progress reports](http://www.encode.io/reports/march-2017) and regularly include financial reports and cost breakdowns.
|
||||
|
||||
<!-- Begin MailChimp Signup Form -->
|
||||
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
|
||||
|
|
|
@ -81,7 +81,7 @@ If you're translating a new language you'll need to translate the existing REST
|
|||
|
||||
4. Edit the `django.po` file you've just copied, translating all the error messages.
|
||||
|
||||
5. Run `manage.py compilemessages -l pt_BR` to make the translations
|
||||
5. Run `manage.py compilemessages -l pt_BR` to make the translations
|
||||
available for Django to use. You should see a message like `processing file django.po in <...>/locale/pt_BR/LC_MESSAGES`.
|
||||
|
||||
6. Restart your development server to see the changes take effect.
|
||||
|
@ -106,7 +106,7 @@ For API clients the most appropriate of these will typically be to use the `Acce
|
|||
[django-translation]: https://docs.djangoproject.com/en/1.7/topics/i18n/translation
|
||||
[custom-exception-handler]: ../api-guide/exceptions.md#custom-exception-handling
|
||||
[transifex-project]: https://www.transifex.com/projects/p/django-rest-framework/
|
||||
[django-po-source]: https://raw.githubusercontent.com/tomchristie/django-rest-framework/master/rest_framework/locale/en_US/LC_MESSAGES/django.po
|
||||
[django-po-source]: https://raw.githubusercontent.com/encode/django-rest-framework/master/rest_framework/locale/en_US/LC_MESSAGES/django.po
|
||||
[django-language-preference]: https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#how-django-discovers-language-preference
|
||||
[django-locale-paths]: https://docs.djangoproject.com/en/1.7/ref/settings/#std:setting-LOCALE_PATHS
|
||||
[django-locale-name]: https://docs.djangoproject.com/en/1.7/topics/i18n/#term-locale-name
|
||||
|
|
|
@ -35,5 +35,5 @@ Wonder how else you can help? One of the best ways you can help Django REST Fram
|
|||
[remoteok-io]: https://remoteok.io/remote-django-jobs
|
||||
[remotepython-com]: https://www.remotepython.com/jobs/
|
||||
[drf-funding]: https://fund.django-rest-framework.org/topics/funding/
|
||||
[submit-pr]: https://github.com/tomchristie/django-rest-framework
|
||||
[submit-pr]: https://github.com/encode/django-rest-framework
|
||||
[anna-email]: mailto:anna@django-rest-framework.org
|
||||
|
|
|
@ -17,9 +17,9 @@ We have a quarterly maintenance cycle where new members may join the maintenance
|
|||
|
||||
#### Current team
|
||||
|
||||
The [maintenance team for Q4 2015](https://github.com/tomchristie/django-rest-framework/issues/2190):
|
||||
The [maintenance team for Q4 2015](https://github.com/encode/django-rest-framework/issues/2190):
|
||||
|
||||
* [@tomchristie](https://github.com/tomchristie/)
|
||||
* [@tomchristie](https://github.com/encode/)
|
||||
* [@xordoquy](https://github.com/xordoquy/) (Release manager.)
|
||||
* [@carltongibson](https://github.com/carltongibson/)
|
||||
* [@kevin-brown](https://github.com/kevin-brown/)
|
||||
|
@ -104,9 +104,9 @@ The following template should be used for the description of the issue, and serv
|
|||
|
||||
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/encode/django-rest-framework/blob/master/docs/topics/release-notes.md) based on the [*.*.* milestone](https://github.com/encode/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/encode/django-rest-framework/blob/master/rest_framework/__init__.py).
|
||||
- [ ] Confirm with @tomchristie that release is finalized and ready to go.
|
||||
- [ ] Ensure that release date is included in pull request.
|
||||
- [ ] Merge the release pull request.
|
||||
|
@ -197,10 +197,10 @@ The following issues still need to be addressed:
|
|||
* Document ownership and management of the security mailing list.
|
||||
|
||||
[bus-factor]: http://en.wikipedia.org/wiki/Bus_factor
|
||||
[un-triaged]: https://github.com/tomchristie/django-rest-framework/issues?q=is%3Aopen+no%3Alabel
|
||||
[un-triaged]: https://github.com/encode/django-rest-framework/issues?q=is%3Aopen+no%3Alabel
|
||||
[transifex-project]: https://www.transifex.com/projects/p/django-rest-framework/
|
||||
[transifex-client]: https://pypi.python.org/pypi/transifex-client
|
||||
[translation-memory]: http://docs.transifex.com/guides/tm#let-tm-automatically-populate-translations
|
||||
[github-org]: https://github.com/tomchristie/django-rest-framework/issues/2162
|
||||
[github-org]: https://github.com/encode/django-rest-framework/issues/2162
|
||||
[sandbox]: http://restframework.herokuapp.com/
|
||||
[mailing-list]: https://groups.google.com/forum/#!forum/django-rest-framework
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -190,6 +190,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
|
|||
* [djoser][djoser] - Provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation.
|
||||
* [django-rest-auth][django-rest-auth] - Provides a set of REST API endpoints for registration, authentication (including social media authentication), password reset, retrieve and update user details, etc.
|
||||
* [drf-oidc-auth][drf-oidc-auth] - Implements OpenID Connect token authentication for DRF.
|
||||
* [drfpasswordless][drfpasswordless] - Adds (Medium, Square Cash inspired) passwordless logins and signups via email and mobile numbers.
|
||||
|
||||
### Permissions
|
||||
|
||||
|
@ -271,10 +272,10 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
|
|||
[pypi-register]: https://pypi.python.org/pypi?%3Aaction=register_form
|
||||
[semver]: http://semver.org/
|
||||
[tox-docs]: https://tox.readthedocs.io/en/latest/
|
||||
[drf-compat]: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/compat.py
|
||||
[drf-compat]: https://github.com/encode/django-rest-framework/blob/master/rest_framework/compat.py
|
||||
[rest-framework-grid]: https://www.djangopackages.com/grids/g/django-rest-framework/
|
||||
[drf-create-pr]: https://github.com/tomchristie/django-rest-framework/compare
|
||||
[drf-create-issue]: https://github.com/tomchristie/django-rest-framework/issues/new
|
||||
[drf-create-pr]: https://github.com/encode/django-rest-framework/compare
|
||||
[drf-create-issue]: https://github.com/encode/django-rest-framework/issues/new
|
||||
[authentication]: ../api-guide/authentication.md
|
||||
[permissions]: ../api-guide/permissions.md
|
||||
[third-party-packages]: ../topics/third-party-packages/#existing-third-party-packages
|
||||
|
@ -330,3 +331,4 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
|
|||
[drf-oidc-auth]: https://github.com/ByteInternet/drf-oidc-auth
|
||||
[drf-serializer-extensions]: https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions
|
||||
[djangorestframework-queryfields]: https://github.com/wimglenn/djangorestframework-queryfields
|
||||
[drfpasswordless]: https://github.com/aaronn/django-rest-framework-passwordless
|
||||
|
|
|
@ -106,5 +106,5 @@ Want your Django REST Framework talk/tutorial/article to be added to our website
|
|||
[drf-an-intro]: https://realpython.com/blog/python/django-rest-framework-quick-start/
|
||||
[drf-tutorial]: https://tests4geeks.com/django-rest-framework-tutorial/
|
||||
[building-a-restful-api-with-drf]: http://agiliq.com/blog/2014/12/building-a-restful-api-with-django-rest-framework/
|
||||
[submit-pr]: https://github.com/tomchristie/django-rest-framework
|
||||
[submit-pr]: https://github.com/encode/django-rest-framework
|
||||
[anna-email]: mailto:anna@django-rest-framework.org
|
||||
|
|
|
@ -373,7 +373,7 @@ Our API views don't do anything particularly special at the moment, beyond servi
|
|||
We'll see how we can start to improve things in [part 2 of the tutorial][tut-2].
|
||||
|
||||
[quickstart]: quickstart.md
|
||||
[repo]: https://github.com/tomchristie/rest-framework-tutorial
|
||||
[repo]: https://github.com/encode/rest-framework-tutorial
|
||||
[sandbox]: http://restframework.herokuapp.com/
|
||||
[virtualenv]: http://www.virtualenv.org/en/latest/index.html
|
||||
[tut-2]: 2-requests-and-responses.md
|
||||
|
|
|
@ -41,7 +41,7 @@ view in our URL configuration.
|
|||
schema_view = get_schema_view(title='Pastebin API')
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^schema/$', schema_view),
|
||||
url(r'^schema/$', schema_view),
|
||||
...
|
||||
]
|
||||
|
||||
|
@ -221,8 +221,8 @@ We've reached the end of our tutorial. If you want to get more involved in the
|
|||
[coreapi]: http://www.coreapi.org
|
||||
[corejson]: http://www.coreapi.org/specification/encoding/#core-json-encoding
|
||||
[openapi]: https://openapis.org/
|
||||
[repo]: https://github.com/tomchristie/rest-framework-tutorial
|
||||
[repo]: https://github.com/encode/rest-framework-tutorial
|
||||
[sandbox]: http://restframework.herokuapp.com/
|
||||
[github]: https://github.com/tomchristie/django-rest-framework
|
||||
[github]: https://github.com/encode/django-rest-framework
|
||||
[group]: https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework
|
||||
[twitter]: https://twitter.com/_tomchristie
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "base.html" %}
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>{% if page_title %}{{ page_title }} - {% endif %}{{ site_name }}</title>
|
||||
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ config.site_name }}</title>
|
||||
<link href="{{ base_url }}/img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="{{ canonical_url }}" />
|
||||
<link rel="canonical" href="{{ page.canonical_url }}" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Django, API, REST{% if current_page %}, {{ current_page.title }}{% endif %}">
|
||||
<meta name="description" content="Django, API, REST{% if page %}, {{ page.title }}{% endif %}">
|
||||
<meta name="author" content="Tom Christie">
|
||||
|
||||
<!-- Le styles -->
|
||||
|
@ -51,7 +51,7 @@
|
|||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="prettyPrint()" class="{% if current_page and current_page.is_homepage %}index{% endif %}-page">
|
||||
<body onload="prettyPrint()" class="{% if page and page.is_homepage %}index{% endif %}-page">
|
||||
|
||||
<div class="wrapper">
|
||||
{% include "nav.html" %}
|
||||
|
@ -83,14 +83,14 @@
|
|||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
{% if current_page and current_page.is_homepage %}
|
||||
{% if page and page.is_homepage %}
|
||||
<li class="main">
|
||||
<a href="#">Django REST framework</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% for toc_item in toc %}
|
||||
<li class="{% if current_page and not current_page.is_homepage %}main{% endif %}">
|
||||
{% for toc_item in page.toc %}
|
||||
<li class="{% if page and not page.is_homepage %}main{% endif %}">
|
||||
<a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
|
||||
</li>
|
||||
|
||||
|
@ -112,15 +112,15 @@
|
|||
|
||||
<div id="main-content" class="span9">
|
||||
{% block content %}
|
||||
{% if meta.source %}
|
||||
{% for filename in meta.source %}
|
||||
<a class="github" href="https://github.com/tomchristie/django-rest-framework/tree/master/rest_framework/{{ filename }}">
|
||||
{% if page.meta.source %}
|
||||
{% for filename in page.meta.source %}
|
||||
<a class="github" href="https://github.com/encode/django-rest-framework/tree/master/rest_framework/{{ filename }}">
|
||||
<span class="label label-info">{{ filename }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{{ content }}
|
||||
{{ page.content }}
|
||||
{% endblock %}
|
||||
|
||||
</div> <!--/span-->
|
|
@ -1,11 +1,11 @@
|
|||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small {% if not next_page %}disabled{% endif %}" rel="prev" {% if next_page %}href="{{ next_page.url }}"{% endif %}>
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/encode/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small {% if not page.next_page %}disabled{% endif %}" rel="prev" {% if page.next_page %}href="{{ page.next_page.url }}"{% endif %}>
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<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 page.previous_page %}disabled{% endif %}" rel="next" {% if page.previous_page %}href="{{ page.previous_page.url }}"{% endif %}>
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</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>
|
||||
|
@ -16,7 +16,7 @@
|
|||
</a>
|
||||
<a class="brand" href="http://www.django-rest-framework.org">Django REST framework</a>
|
||||
<div class="nav-collapse collapse">
|
||||
{% if include_nav %}
|
||||
{% if nav|length>1 %}
|
||||
<!-- Main navigation -->
|
||||
<ul class="nav navbar-nav">
|
||||
{% for nav_item in nav %} {% if nav_item.children %}
|
||||
|
|
|
@ -2,7 +2,7 @@ site_name: Django REST framework
|
|||
site_url: http://www.django-rest-framework.org/
|
||||
site_description: Django REST framework - Web APIs for Django
|
||||
|
||||
repo_url: https://github.com/tomchristie/django-rest-framework
|
||||
repo_url: https://github.com/encode/django-rest-framework
|
||||
|
||||
theme_dir: docs_theme
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
# MkDocs to build our documentation.
|
||||
mkdocs==0.15.3
|
||||
mkdocs==0.16.2
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Optional packages which may be used with REST framework.
|
||||
markdown==2.6.4
|
||||
django-guardian==1.4.6
|
||||
django-guardian==1.4.8
|
||||
django-filter==1.0.0
|
||||
coreapi==2.2.4
|
||||
coreschema==0.0.4
|
||||
|
|
|
@ -24,7 +24,7 @@ class Token(models.Model):
|
|||
# https://code.djangoproject.com/ticket/19422
|
||||
#
|
||||
# Also see corresponding ticket:
|
||||
# https://github.com/tomchristie/django-rest-framework/issues/705
|
||||
# https://github.com/encode/django-rest-framework/issues/705
|
||||
abstract = 'rest_framework.authtoken' not in settings.INSTALLED_APPS
|
||||
verbose_name = _("Token")
|
||||
verbose_name_plural = _("Tokens")
|
||||
|
|
|
@ -618,8 +618,8 @@ class Field(object):
|
|||
originally created with, rather than copying the complete state.
|
||||
"""
|
||||
# Treat regexes and validators as immutable.
|
||||
# See https://github.com/tomchristie/django-rest-framework/issues/1954
|
||||
# and https://github.com/tomchristie/django-rest-framework/pull/4489
|
||||
# See https://github.com/encode/django-rest-framework/issues/1954
|
||||
# and https://github.com/encode/django-rest-framework/pull/4489
|
||||
args = [
|
||||
copy.deepcopy(item) if not isinstance(item, REGEX_TYPE) else item
|
||||
for item in self._args
|
||||
|
@ -649,6 +649,7 @@ class BooleanField(Field):
|
|||
initial = False
|
||||
TRUE_VALUES = {
|
||||
't', 'T',
|
||||
'y', 'Y', 'yes', 'YES',
|
||||
'true', 'True', 'TRUE',
|
||||
'on', 'On', 'ON',
|
||||
'1', 1,
|
||||
|
@ -656,6 +657,7 @@ class BooleanField(Field):
|
|||
}
|
||||
FALSE_VALUES = {
|
||||
'f', 'F',
|
||||
'n', 'N', 'no', 'NO',
|
||||
'false', 'False', 'FALSE',
|
||||
'off', 'Off', 'OFF',
|
||||
'0', 0, 0.0,
|
||||
|
|
|
@ -323,7 +323,7 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend):
|
|||
|
||||
def filter_queryset(self, request, queryset, view):
|
||||
# We want to defer this import until run-time, rather than import-time.
|
||||
# See https://github.com/tomchristie/django-rest-framework/issues/4608
|
||||
# See https://github.com/encode/django-rest-framework/issues/4608
|
||||
# (Also see #1624 for why we need to make this import explicitly)
|
||||
from guardian.shortcuts import get_objects_for_user
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ REST_FRAMEWORK = {
|
|||
)
|
||||
'DEFAULT_PARSER_CLASSES': (
|
||||
'rest_framework.parsers.JSONParser',
|
||||
'rest_framework.parsers.TemplateHTMLRenderer',
|
||||
'rest_framework.parsers.FormParser',
|
||||
'rest_framework.parsers.MultiPartParser'
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -24,11 +24,12 @@ def get_breadcrumbs(url, request=None):
|
|||
# Check if this is a REST framework view,
|
||||
# and if so add it to the breadcrumbs
|
||||
cls = getattr(view, 'cls', None)
|
||||
initkwargs = getattr(view, 'initkwargs', {})
|
||||
if cls is not None and issubclass(cls, APIView):
|
||||
# Don't list the same view twice in a row.
|
||||
# Probably an optional trailing slash.
|
||||
if not seen or seen[-1] != view:
|
||||
c = cls()
|
||||
c = cls(**initkwargs)
|
||||
c.suffix = getattr(view, 'suffix', None)
|
||||
name = c.get_view_name()
|
||||
insert_url = preserve_builtin_query_params(prefix + url, request)
|
||||
|
|
|
@ -123,18 +123,70 @@ def get_field_kwargs(field_name, model_field):
|
|||
kwargs['allow_folders'] = model_field.allow_folders
|
||||
|
||||
if model_field.choices:
|
||||
# If this model field contains choices, then return early.
|
||||
# Further keyword arguments are not valid.
|
||||
kwargs['choices'] = model_field.choices
|
||||
return kwargs
|
||||
else:
|
||||
# Ensure that max_value is passed explicitly as a keyword arg,
|
||||
# rather than as a validator.
|
||||
max_value = next((
|
||||
validator.limit_value for validator in validator_kwarg
|
||||
if isinstance(validator, validators.MaxValueValidator)
|
||||
), None)
|
||||
if max_value is not None and isinstance(model_field, NUMERIC_FIELD_TYPES):
|
||||
kwargs['max_value'] = max_value
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, validators.MaxValueValidator)
|
||||
]
|
||||
|
||||
# Our decimal validation is handled in the field code, not validator code.
|
||||
# (In Django 1.9+ this differs from previous style)
|
||||
if isinstance(model_field, models.DecimalField) and DecimalValidator:
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, DecimalValidator)
|
||||
]
|
||||
# Ensure that max_value is passed explicitly as a keyword arg,
|
||||
# rather than as a validator.
|
||||
min_value = next((
|
||||
validator.limit_value for validator in validator_kwarg
|
||||
if isinstance(validator, validators.MinValueValidator)
|
||||
), None)
|
||||
if min_value is not None and isinstance(model_field, NUMERIC_FIELD_TYPES):
|
||||
kwargs['min_value'] = min_value
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, validators.MinValueValidator)
|
||||
]
|
||||
|
||||
# URLField does not need to include the URLValidator argument,
|
||||
# as it is explicitly added in.
|
||||
if isinstance(model_field, models.URLField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, validators.URLValidator)
|
||||
]
|
||||
|
||||
# EmailField does not need to include the validate_email argument,
|
||||
# as it is explicitly added in.
|
||||
if isinstance(model_field, models.EmailField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if validator is not validators.validate_email
|
||||
]
|
||||
|
||||
# SlugField do not need to include the 'validate_slug' argument,
|
||||
if isinstance(model_field, models.SlugField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if validator is not validators.validate_slug
|
||||
]
|
||||
|
||||
# IPAddressField do not need to include the 'validate_ipv46_address' argument,
|
||||
if isinstance(model_field, models.GenericIPAddressField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if validator is not validators.validate_ipv46_address
|
||||
]
|
||||
# Our decimal validation is handled in the field code, not validator code.
|
||||
# (In Django 1.9+ this differs from previous style)
|
||||
if isinstance(model_field, models.DecimalField) and DecimalValidator:
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, DecimalValidator)
|
||||
]
|
||||
|
||||
# Ensure that max_length is passed explicitly as a keyword arg,
|
||||
# rather than as a validator.
|
||||
|
@ -160,62 +212,6 @@ def get_field_kwargs(field_name, model_field):
|
|||
if not isinstance(validator, validators.MinLengthValidator)
|
||||
]
|
||||
|
||||
# Ensure that max_value is passed explicitly as a keyword arg,
|
||||
# rather than as a validator.
|
||||
max_value = next((
|
||||
validator.limit_value for validator in validator_kwarg
|
||||
if isinstance(validator, validators.MaxValueValidator)
|
||||
), None)
|
||||
if max_value is not None and isinstance(model_field, NUMERIC_FIELD_TYPES):
|
||||
kwargs['max_value'] = max_value
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, validators.MaxValueValidator)
|
||||
]
|
||||
|
||||
# Ensure that max_value is passed explicitly as a keyword arg,
|
||||
# rather than as a validator.
|
||||
min_value = next((
|
||||
validator.limit_value for validator in validator_kwarg
|
||||
if isinstance(validator, validators.MinValueValidator)
|
||||
), None)
|
||||
if min_value is not None and isinstance(model_field, NUMERIC_FIELD_TYPES):
|
||||
kwargs['min_value'] = min_value
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, validators.MinValueValidator)
|
||||
]
|
||||
|
||||
# URLField does not need to include the URLValidator argument,
|
||||
# as it is explicitly added in.
|
||||
if isinstance(model_field, models.URLField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if not isinstance(validator, validators.URLValidator)
|
||||
]
|
||||
|
||||
# EmailField does not need to include the validate_email argument,
|
||||
# as it is explicitly added in.
|
||||
if isinstance(model_field, models.EmailField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if validator is not validators.validate_email
|
||||
]
|
||||
|
||||
# SlugField do not need to include the 'validate_slug' argument,
|
||||
if isinstance(model_field, models.SlugField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if validator is not validators.validate_slug
|
||||
]
|
||||
|
||||
# IPAddressField do not need to include the 'validate_ipv46_address' argument,
|
||||
if isinstance(model_field, models.GenericIPAddressField):
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if validator is not validators.validate_ipv46_address
|
||||
]
|
||||
|
||||
if getattr(model_field, 'unique', False):
|
||||
unique_error_message = model_field.error_messages.get('unique', None)
|
||||
if unique_error_message:
|
||||
|
|
|
@ -18,7 +18,7 @@ from rest_framework.utils.representation import smart_repr
|
|||
|
||||
# Robust filter and exist implementations. Ensures that queryset.exists() for
|
||||
# an invalid value returns `False`, rather than raising an error.
|
||||
# Refs https://github.com/tomchristie/django-rest-framework/issues/3381
|
||||
# Refs https://github.com/encode/django-rest-framework/issues/3381
|
||||
|
||||
def qs_exists(queryset):
|
||||
try:
|
||||
|
|
|
@ -9,6 +9,7 @@ from django.db import models
|
|||
from django.http import Http404
|
||||
from django.http.response import HttpResponseBase
|
||||
from django.utils import six
|
||||
from django.utils.cache import cc_delim_re, patch_vary_headers
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
@ -290,7 +291,7 @@ class APIView(View):
|
|||
"""
|
||||
Returns the exception handler that this view uses.
|
||||
"""
|
||||
return api_settings.EXCEPTION_HANDLER
|
||||
return self.settings.EXCEPTION_HANDLER
|
||||
|
||||
# API policy implementation methods
|
||||
|
||||
|
@ -414,6 +415,11 @@ class APIView(View):
|
|||
response.accepted_media_type = request.accepted_media_type
|
||||
response.renderer_context = self.get_renderer_context()
|
||||
|
||||
# Add new vary headers to the response instead of overwriting.
|
||||
vary_headers = self.headers.pop('Vary', None)
|
||||
if vary_headers is not None:
|
||||
patch_vary_headers(response, cc_delim_re.split(vary_headers))
|
||||
|
||||
for key, value in self.headers.items():
|
||||
response[key] = value
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class TestManyPostView(TestCase):
|
|||
POST request to a view that returns a list of objects should
|
||||
still successfully return the browsable API with a rendered form.
|
||||
|
||||
Regression test for https://github.com/tomchristie/django-rest-framework/pull/3164
|
||||
Regression test for https://github.com/encode/django-rest-framework/pull/3164
|
||||
"""
|
||||
data = {}
|
||||
request = factory.post('/', data, format='json')
|
||||
|
|
|
@ -127,7 +127,7 @@ class BasicAuthTests(TestCase):
|
|||
def test_regression_handle_bad_base64_basic_auth_header(self):
|
||||
"""Ensure POSTing JSON over basic auth with incorrectly padded Base64 string is handled correctly"""
|
||||
# regression test for issue in 'rest_framework.authentication.BasicAuthentication.authenticate'
|
||||
# https://github.com/tomchristie/django-rest-framework/issues/4089
|
||||
# https://github.com/encode/django-rest-framework/issues/4089
|
||||
auth = 'Basic =a='
|
||||
response = self.csrf_client.post(
|
||||
'/basic/',
|
||||
|
@ -185,7 +185,7 @@ class SessionAuthTests(TestCase):
|
|||
"""
|
||||
Ensure the login template renders for a basic GET.
|
||||
|
||||
cf. [#1810](https://github.com/tomchristie/django-rest-framework/pull/1810)
|
||||
cf. [#1810](https://github.com/encode/django-rest-framework/pull/1810)
|
||||
"""
|
||||
response = self.csrf_client.get('/auth/login/')
|
||||
content = response.content.decode('utf8')
|
||||
|
|
|
@ -96,7 +96,7 @@ class TestViewNamesAndDescriptions(TestCase):
|
|||
Ensure a view may have a docstring that is actually a lazily evaluated
|
||||
class that can be converted to a string.
|
||||
|
||||
See: https://github.com/tomchristie/django-rest-framework/issues/1708
|
||||
See: https://github.com/encode/django-rest-framework/issues/1708
|
||||
"""
|
||||
# use a mock object instead of gettext_lazy to ensure that we can't end
|
||||
# up with a test case string in our l10n catalog
|
||||
|
|
|
@ -398,7 +398,7 @@ class TestCreateModelWithAutoNowAddField(TestCase):
|
|||
"""
|
||||
Regression test for #285
|
||||
|
||||
https://github.com/tomchristie/django-rest-framework/issues/285
|
||||
https://github.com/encode/django-rest-framework/issues/285
|
||||
"""
|
||||
data = {'email': 'foobar@example.com', 'content': 'foobar'}
|
||||
request = factory.post('/', data, format='json')
|
||||
|
|
|
@ -99,6 +99,15 @@ class Issue3674ChildModel(models.Model):
|
|||
value = models.CharField(primary_key=True, max_length=64)
|
||||
|
||||
|
||||
class UniqueChoiceModel(models.Model):
|
||||
CHOICES = (
|
||||
('choice1', 'choice 1'),
|
||||
('choice2', 'choice 1'),
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=254, unique=True, choices=CHOICES)
|
||||
|
||||
|
||||
class TestModelSerializer(TestCase):
|
||||
def test_create_method(self):
|
||||
class TestSerializer(serializers.ModelSerializer):
|
||||
|
@ -1080,3 +1089,16 @@ class Issue4897TestCase(TestCase):
|
|||
with pytest.raises(AssertionError) as cm:
|
||||
TestSerializer(obj).fields
|
||||
cm.match(r'readonly_fields')
|
||||
|
||||
|
||||
class Test5004UniqueChoiceField(TestCase):
|
||||
def test_unique_choice_field(self):
|
||||
class TestUniqueChoiceSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = UniqueChoiceModel
|
||||
fields = '__all__'
|
||||
|
||||
UniqueChoiceModel.objects.create(name='choice1')
|
||||
serializer = TestUniqueChoiceSerializer(data={'name': 'choice1'})
|
||||
assert not serializer.is_valid()
|
||||
assert serializer.errors == {'name': ['unique choice model with this name already exists.']}
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestPrefetchRelatedUpdates(TestCase):
|
|||
|
||||
def test_prefetch_related_excluding_instance_from_original_queryset(self):
|
||||
"""
|
||||
Regression test for https://github.com/tomchristie/django-rest-framework/issues/4661
|
||||
Regression test for https://github.com/encode/django-rest-framework/issues/4661
|
||||
"""
|
||||
view = UserUpdate.as_view()
|
||||
pk = self.user.pk
|
||||
|
|
|
@ -335,7 +335,7 @@ class PKForeignKeyTests(TestCase):
|
|||
"""
|
||||
Regression test for #1072
|
||||
|
||||
https://github.com/tomchristie/django-rest-framework/issues/1072
|
||||
https://github.com/encode/django-rest-framework/issues/1072
|
||||
"""
|
||||
serializer = NullableForeignKeySourceSerializer()
|
||||
assert serializer.data['target'] is None
|
||||
|
|
|
@ -242,7 +242,7 @@ class RendererEndToEndTests(TestCase):
|
|||
"""
|
||||
Regression test for #1196
|
||||
|
||||
https://github.com/tomchristie/django-rest-framework/issues/1196
|
||||
https://github.com/encode/django-rest-framework/issues/1196
|
||||
"""
|
||||
resp = self.client.get('/empty')
|
||||
self.assertEqual(resp.get('Content-Type', None), None)
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.test import TestCase
|
|||
from rest_framework import status
|
||||
from rest_framework.decorators import api_view
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.settings import APISettings, api_settings
|
||||
from rest_framework.test import APIRequestFactory
|
||||
from rest_framework.views import APIView
|
||||
|
||||
|
@ -45,6 +45,19 @@ class ErrorView(APIView):
|
|||
raise Exception
|
||||
|
||||
|
||||
def custom_handler(exc, context):
|
||||
if isinstance(exc, SyntaxError):
|
||||
return Response({'error': 'SyntaxError'}, status=400)
|
||||
return Response({'error': 'UnknownError'}, status=500)
|
||||
|
||||
|
||||
class OverridenSettingsView(APIView):
|
||||
settings = APISettings({'EXCEPTION_HANDLER': custom_handler})
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
raise SyntaxError('request is invalid syntax')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def error_view(request):
|
||||
raise Exception
|
||||
|
@ -118,3 +131,14 @@ class TestCustomExceptionHandler(TestCase):
|
|||
expected = 'Error!'
|
||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||
assert response.data == expected
|
||||
|
||||
|
||||
class TestCustomSettings(TestCase):
|
||||
def setUp(self):
|
||||
self.view = OverridenSettingsView.as_view()
|
||||
|
||||
def test_get_exception_handler(self):
|
||||
request = factory.get('/', content_type='application/json')
|
||||
response = self.view(request)
|
||||
assert response.status_code == 400
|
||||
assert response.data == {'error': 'SyntaxError'}
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -26,7 +26,7 @@ deps =
|
|||
django18: Django>=1.8,<1.9
|
||||
django19: Django>=1.9,<1.10
|
||||
django110: Django>=1.10,<1.11
|
||||
django111: Django>=1.11rc1,<2.0
|
||||
django111: Django>=1.11,<2.0
|
||||
djangomaster: https://github.com/django/django/archive/master.tar.gz
|
||||
-rrequirements/requirements-testing.txt
|
||||
-rrequirements/requirements-optionals.txt
|
||||
|
|
Loading…
Reference in New Issue
Block a user