diff --git a/LICENSE.md b/LICENSE.md index aca195ec4..4c599a394 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # License -Copyright (c) 2011-2016, Tom Christie +Copyright (c) 2011-2017, Tom Christie All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 609f99184..7d11aa081 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,10 @@ The initial aim is to provide a single full-time position on REST framework. +

-*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/), and [Rollbar](https://rollbar.com).* +*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/).* --- diff --git a/docs/img/premium/micropyramid-readme.png b/docs/img/premium/micropyramid-readme.png new file mode 100644 index 000000000..9fa9500e1 Binary files /dev/null and b/docs/img/premium/micropyramid-readme.png differ diff --git a/docs/index.md b/docs/index.md index 1760ce916..4abfba587 100644 --- a/docs/index.md +++ b/docs/index.md @@ -76,10 +76,11 @@ The initial aim is to provide a single full-time position on REST framework.
  • Stream
  • Machinalis
  • Rollbar
  • +
  • MicroPyramid
  • -*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/), and [Rollbar](https://rollbar.com).* +*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/).* --- @@ -237,7 +238,8 @@ General guides to using REST framework. * [Browser enhancements][browser-enhancements] * [The Browsable API][browsableapi] * [REST, Hypermedia & HATEOAS][rest-hypermedia-hateoas] -* [Third Party Resources][third-party-resources] +* [Third Party Packages][third-party-packages] +* [Tutorials and Resources][tutorials-and-resources] * [Contributing to REST framework][contributing] * [Project management][project-management] * [3.0 Announcement][3.0-announcement] @@ -250,6 +252,7 @@ General guides to using REST framework. * [Mozilla Grant][mozilla-grant] * [Funding][funding] * [Release Notes][release-notes] +* [Jobs][jobs] ## Development @@ -366,7 +369,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [rest-hypermedia-hateoas]: topics/rest-hypermedia-hateoas.md [contributing]: topics/contributing.md [project-management]: topics/project-management.md -[third-party-resources]: topics/third-party-resources.md +[third-party-packages]: topics/third-party-packages.md +[tutorials-and-resources]: topics/tutorials-and-resources.md [3.0-announcement]: topics/3.0-announcement.md [3.1-announcement]: topics/3.1-announcement.md [3.2-announcement]: topics/3.2-announcement.md @@ -377,6 +381,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [mozilla-grant]: topics/mozilla-grant.md [funding]: topics/funding.md [release-notes]: topics/release-notes.md +[jobs]: topics/jobs.md [tox]: http://testrun.org/tox/latest/ diff --git a/docs/topics/jobs.md b/docs/topics/jobs.md new file mode 100644 index 000000000..9c67483a8 --- /dev/null +++ b/docs/topics/jobs.md @@ -0,0 +1,39 @@ +# Jobs + +Looking for a new Django REST Framework related role? On this site we provide a list of job resources that may be helpful. It's also worth checking out if any of [our sponsors are hiring][drf-funding]. + + +## Places to Look for Django REST Framework Jobs + +* [https://www.djangoproject.com/community/jobs/][djangoproject-website] +* [https://www.python.org/jobs/][python-org-jobs] +* [https://djangogigs.com][django-gigs-com] +* [https://djangojobs.net/jobs/][django-jobs-net] +* [http://djangojobbers.com][django-jobbers-com] +* [https://www.indeed.com/q-Django-jobs.html][indeed-com] +* [http://stackoverflow.com/jobs/developer-jobs-using-django][stackoverflow-com] +* [https://www.upwork.com/o/jobs/browse/skill/django-framework/][upwork-com] +* [https://www.technojobs.co.uk/django-jobs][technobjobs-co-uk] +* [https://remoteok.io/remote-django-jobs][remoteok-io] +* [https://www.remotepython.com/jobs/][remotepython-com] + + +Know of any other great resources for Django REST Framework jobs that are missing in our list? Please [submit a pull request][submit-pr] or [email us][anna-email]. + +Wonder how else you can help? One of the best ways you can help Django REST Framework is to ask interviewers if their company is signed up for [REST Framework sponsorship][drf-funding] yet. + + +[djangoproject-website]: https://www.djangoproject.com/community/jobs/ +[python-org-jobs]: https://www.python.org/jobs/ +[django-gigs-com]: https://djangogigs.com +[django-jobs-net]: https://djangojobs.net/jobs/ +[django-jobbers-com]: http://djangojobbers.com +[indeed-com]: https://www.indeed.com/q-Django-jobs.html +[stackoverflow-com]: http://stackoverflow.com/jobs/developer-jobs-using-django +[upwork-com]: https://www.upwork.com/o/jobs/browse/skill/django-framework/ +[technobjobs-co-uk]: https://www.technojobs.co.uk/django-jobs +[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 +[anna-email]: mailto:anna@django-rest-framework.org diff --git a/docs/topics/third-party-resources.md b/docs/topics/third-party-packages.md similarity index 85% rename from docs/topics/third-party-resources.md rename to docs/topics/third-party-packages.md index 1ccedbc01..d092e163e 100644 --- a/docs/topics/third-party-resources.md +++ b/docs/topics/third-party-packages.md @@ -1,4 +1,4 @@ -# Third Party Resources +# Third Party Packages > Software ecosystems […] establish a community that further accelerates the sharing of knowledge, content, issues, expertise and skills. > @@ -165,7 +165,7 @@ We suggest adding your package to the [REST Framework][rest-framework-grid] grid #### Adding to the Django REST framework docs -Create a [Pull Request][drf-create-pr] or [Issue][drf-create-issue] on GitHub, and we'll add a link to it from the main REST framework documentation. You can add your package under **Third party packages** of the API Guide section that best applies, like [Authentication][authentication] or [Permissions][permissions]. You can also link your package under the [Third Party Resources][third-party-resources] section. +Create a [Pull Request][drf-create-pr] or [Issue][drf-create-issue] on GitHub, and we'll add a link to it from the main REST framework documentation. You can add your package under **Third party packages** of the API Guide section that best applies, like [Authentication][authentication] or [Permissions][permissions]. You can also link your package under the [Third Party Packages][third-party-packages] section. #### Announce on the discussion group. @@ -261,33 +261,6 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque * [django-rest-framework-version-transforms][django-rest-framework-version-transforms] - Enables the use of delta transformations for versioning of DRF resource representations. * [django-rest-messaging][django-rest-messaging], [django-rest-messaging-centrifugo][django-rest-messaging-centrifugo] and [django-rest-messaging-js][django-rest-messaging-js] - A real-time pluggable messaging service using DRM. -## Other Resources - -### Tutorials - -* [Beginner's Guide to the Django Rest Framework][beginners-guide-to-the-django-rest-framework] -* [Getting Started with Django Rest Framework and AngularJS][getting-started-with-django-rest-framework-and-angularjs] -* [End to end web app with Django-Rest-Framework & AngularJS][end-to-end-web-app-with-django-rest-framework-angularjs] -* [Start Your API - django-rest-framework part 1][start-your-api-django-rest-framework-part-1] -* [Permissions & Authentication - django-rest-framework part 2][permissions-authentication-django-rest-framework-part-2] -* [ViewSets and Routers - django-rest-framework part 3][viewsets-and-routers-django-rest-framework-part-3] -* [Django Rest Framework User Endpoint][django-rest-framework-user-endpoint] -* [Check credentials using Django Rest Framework][check-credentials-using-django-rest-framework] -* [Django REST Framework course][django-rest-framework-course] - -### Videos - -* [Ember and Django Part 1 (Video)][ember-and-django-part 1-video] -* [Django Rest Framework Part 1 (Video)][django-rest-framework-part-1-video] - -### Articles - -* [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] -* [Blog posts about Django REST framework][medium-django-rest-framework] - -### Documentations -* [Classy Django REST Framework][cdrf.co] [cite]: http://www.software-ecosystems.com/Software_Ecosystems/Ecosystems.html [cookiecutter]: https://github.com/jpadilla/cookiecutter-django-rest-framework @@ -304,7 +277,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque [drf-create-issue]: https://github.com/tomchristie/django-rest-framework/issues/new [authentication]: ../api-guide/authentication.md [permissions]: ../api-guide/permissions.md -[third-party-resources]: ../topics/third-party-resources/#existing-third-party-packages +[third-party-packages]: ../topics/third-party-packages/#existing-third-party-packages [discussion-group]: https://groups.google.com/forum/#!forum/django-rest-framework [djangorestframework-digestauth]: https://github.com/juanriaza/django-rest-framework-digestauth [django-oauth-toolkit]: https://github.com/evonove/django-oauth-toolkit @@ -337,22 +310,9 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque [gaiarestframework]: https://github.com/AppsFuel/gaiarestframework [drf-extensions]: https://github.com/chibisov/drf-extensions [ember-django-adapter]: https://github.com/dustinfarris/ember-django-adapter -[beginners-guide-to-the-django-rest-framework]: http://code.tutsplus.com/tutorials/beginners-guide-to-the-django-rest-framework--cms-19786 -[getting-started-with-django-rest-framework-and-angularjs]: http://blog.kevinastone.com/getting-started-with-django-rest-framework-and-angularjs.html -[end-to-end-web-app-with-django-rest-framework-angularjs]: http://mourafiq.com/2013/07/01/end-to-end-web-app-with-django-angular-1.html -[start-your-api-django-rest-framework-part-1]: https://godjango.com/41-start-your-api-django-rest-framework-part-1/ -[permissions-authentication-django-rest-framework-part-2]: https://godjango.com/43-permissions-authentication-django-rest-framework-part-2/ -[viewsets-and-routers-django-rest-framework-part-3]: https://godjango.com/45-viewsets-and-routers-django-rest-framework-part-3/ -[django-rest-framework-user-endpoint]: http://richardtier.com/2014/02/25/django-rest-framework-user-endpoint/ -[check-credentials-using-django-rest-framework]: http://richardtier.com/2014/03/06/110/ -[ember-and-django-part 1-video]: http://www.neckbeardrepublic.com/screencasts/ember-and-django-part-1 -[django-rest-framework-part-1-video]: http://www.neckbeardrepublic.com/screencasts/django-rest-framework-part-1 -[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/ [django-rest-auth]: https://github.com/Tivix/django-rest-auth/ [django-versatileimagefield]: https://github.com/WGBH/django-versatileimagefield [django-versatileimagefield-drf-docs]:https://django-versatileimagefield.readthedocs.io/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 [dry-rest-permissions]: https://github.com/Helioscene/dry-rest-permissions @@ -366,8 +326,6 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque [django-rest-messaging]: https://github.com/raphaelgyory/django-rest-messaging [django-rest-messaging-centrifugo]: https://github.com/raphaelgyory/django-rest-messaging-centrifugo [django-rest-messaging-js]: https://github.com/raphaelgyory/django-rest-messaging-js -[medium-django-rest-framework]: https://medium.com/django-rest-framework -[django-rest-framework-course]: https://teamtreehouse.com/library/django-rest-framework [drf_tweaks]: https://github.com/ArabellaTech/drf_tweaks [drf-oidc-auth]: https://github.com/ByteInternet/drf-oidc-auth [drf-serializer-extensions]: https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions diff --git a/docs/topics/tutorials-and-resources.md b/docs/topics/tutorials-and-resources.md new file mode 100644 index 000000000..3bbe52e44 --- /dev/null +++ b/docs/topics/tutorials-and-resources.md @@ -0,0 +1,109 @@ +# Tutorials and Resources + +There are a wide range of resources available for learning and using Django REST framework. We try to keep a comprehensive list available here. + +## Tutorials + +* [Beginner's Guide to the Django REST Framework][beginners-guide-to-the-django-rest-framework] +* [Django REST Framework - An Introduction][drf-an-intro] +* [Django REST Framework Tutorial][drf-tutorial] +* [Django REST Framework Course][django-rest-framework-course] +* [Building a RESTful API with Django REST Framework][building-a-restful-api-with-drf] +* [Getting Started with Django REST Framework and AngularJS][getting-started-with-django-rest-framework-and-angularjs] +* [End to End Web App with Django REST Framework & AngularJS][end-to-end-web-app-with-django-rest-framework-angularjs] +* [Start Your API - Django REST Framework Part 1][start-your-api-django-rest-framework-part-1] +* [Permissions & Authentication - Django REST Framework Part 2][permissions-authentication-django-rest-framework-part-2] +* [ViewSets and Routers - Django REST Framework Part 3][viewsets-and-routers-django-rest-framework-part-3] +* [Django REST Framework User Endpoint][django-rest-framework-user-endpoint] +* [Check Credentials Using Django REST Framework][check-credentials-using-django-rest-framework] +* [Creating a Production Ready API with Python and Django REST Framework – Part 1][creating-a-production-ready-api-with-python-and-drf-part1] +* [Creating a Production Ready API with Python and Django REST Framework – Part 2][creating-a-production-ready-api-with-python-and-drf-part2] + + +## Videos + +### Talks + +* [How to Make a Full Fledged REST API with Django OAuth Toolkit][full-fledged-rest-api-with-django-oauth-tookit] +* [Django REST API - So Easy You Can Learn It in 25 Minutes][django-rest-api-so-easy] +* [Tom Christie about Django Rest Framework at Django: Under The Hood][django-under-hood-2014] +* [Django REST Framework: Schemas, Hypermedia & Client Libraries][pycon-uk-2016] + + +### Tutorials + + +* [Django REST Framework Part 1][django-rest-framework-part-1-video] +* [Django REST Framework in Your PJ's!][drf-in-your-pjs] +* [Building a REST API Using Django & Django REST Framework][building-a-rest-api-using-django-and-drf] +* [Blog API with Django REST Framework][blog-api-with-drf] +* [Ember and Django Part 1][ember-and-django-part 1-video] +* [Django REST Framework Image Upload Tutorial (with AngularJS)][drf-image-upload-tutorial-with-angularjs] +* [Django REST Framework Tutorials][drf-tutorials] + + +## Articles + +* [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] +* [Integrating Pandas, Django REST Framework and Bokeh][integrating-pandas-drf-and-bokeh] +* [Controlling Uncertainty on Web Applications and APIs][controlling-uncertainty-on-web-apps-and-apis] +* [Full Text Search in Django REST Framework with Database Backends][full-text-search-in-drf] +* [OAuth2 Authentication with Django REST Framework and Custom Third-Party OAuth2 Backends][oauth2-authentication-with-drf] +* [Nested Resources with Django REST Framework][nested-resources-with-drf] +* [Image Fields with Django REST Framework][image-fields-with-drf] +* [Chatbot Using Django REST Framework + api.ai + Slack — Part 1/3][chatbot-using-drf-part1] +* [New Django Admin with DRF and EmberJS... What are the News?][new-django-admin-with-drf-and-emberjs] +* [Blog posts about Django REST Framework][medium-django-rest-framework] + +## Books + +* [Hello Web App: Intermediate Concepts, Chapter 10][hello-web-app-intermediate] + +### Documentations +* [Classy Django REST Framework][cdrf.co] +* [DRF-schema-adapter][drf-schema] + +Want your Django REST Framework talk/tutorial/article to be added to our website? Or know of a resource that's not yet included here? Please [submit a pull request][submit-pr] or [email us][mailto:anna@django-rest-framework.org]! + + +[beginners-guide-to-the-django-rest-framework]: http://code.tutsplus.com/tutorials/beginners-guide-to-the-django-rest-framework--cms-19786 +[getting-started-with-django-rest-framework-and-angularjs]: http://blog.kevinastone.com/getting-started-with-django-rest-framework-and-angularjs.html +[end-to-end-web-app-with-django-rest-framework-angularjs]: http://mourafiq.com/2013/07/01/end-to-end-web-app-with-django-angular-1.html +[start-your-api-django-rest-framework-part-1]: https://godjango.com/41-start-your-api-django-rest-framework-part-1/ +[permissions-authentication-django-rest-framework-part-2]: https://godjango.com/43-permissions-authentication-django-rest-framework-part-2/ +[viewsets-and-routers-django-rest-framework-part-3]: https://godjango.com/45-viewsets-and-routers-django-rest-framework-part-3/ +[django-rest-framework-user-endpoint]: http://richardtier.com/2014/02/25/django-rest-framework-user-endpoint/ +[check-credentials-using-django-rest-framework]: http://richardtier.com/2014/03/06/110/ +[ember-and-django-part 1-video]: http://www.neckbeardrepublic.com/screencasts/ember-and-django-part-1 +[django-rest-framework-part-1-video]: http://www.neckbeardrepublic.com/screencasts/django-rest-framework-part-1 +[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/ +[cdrf.co]:http://www.cdrf.co +[medium-django-rest-framework]: https://medium.com/django-rest-framework +[django-rest-framework-course]: https://teamtreehouse.com/library/django-rest-framework +[pycon-uk-2016]: https://www.youtube.com/watch?v=FjmiGh7OqVg +[django-under-hood-2014]: https://www.youtube.com/watch?v=3cSsbe-tA0E +[integrating-pandas-drf-and-bokeh]: http://machinalis.com/blog/pandas-django-rest-framework-bokeh/ +[controlling-uncertainty-on-web-apps-and-apis]: http://machinalis.com/blog/controlling-uncertainty-on-web-applications-and-apis/ +[full-text-search-in-drf]: http://machinalis.com/blog/full-text-search-on-django-rest-framework/ +[oauth2-authentication-with-drf]: http://machinalis.com/blog/oauth2-authentication/ +[nested-resources-with-drf]: http://machinalis.com/blog/nested-resources-with-django/ +[image-fields-with-drf]: http://machinalis.com/blog/image-fields-with-django-rest-framework/ +[chatbot-using-drf-part1]: https://chatbotslife.com/chatbot-using-django-rest-framework-api-ai-slack-part-1-3-69c7e38b7b1e#.g2aceuncf +[new-django-admin-with-drf-and-emberjs]: https://blog.levit.be/new-django-admin-with-emberjs-what-are-the-news/ +[drf-schema]: http://drf-schema-adapter.readthedocs.io/en/latest/ +[creating-a-production-ready-api-with-python-and-drf-part1]: https://www.andreagrandi.it/2016/09/28/creating-production-ready-api-python-django-rest-framework-part-1/ +[creating-a-production-ready-api-with-python-and-drf-part2]: https://www.andreagrandi.it/2016/10/01/creating-a-production-ready-api-with-python-and-django-rest-framework-part-2/ +[hello-web-app-intermediate]: https://hellowebapp.com/order/ +[django-rest-api-so-easy]: https://www.youtube.com/watch?v=cqP758k1BaQ +[full-fledged-rest-api-with-django-oauth-tookit]: https://www.youtube.com/watch?v=M6Ud3qC2tTk +[drf-in-your-pjs]: https://www.youtube.com/watch?v=xMtHsWa72Ww +[building-a-rest-api-using-django-and-drf]: https://www.youtube.com/watch?v=PwssEec3IRw +[drf-tutorials]: https://www.youtube.com/watch?v=axRCBgbOJp8&list=PLJtp8Jm8EDzjgVg9vVyIUMoGyqtegj7FH +[drf-image-upload-tutorial-with-angularjs]: https://www.youtube.com/watch?v=hMiNTCIY7dw&list=PLUe5s-xycYk_X0vDjYBmKuIya2a2myF8O +[blog-api-with-drf]: https://www.youtube.com/watch?v=XMu0T6L2KRQ&list=PLEsfXFp6DpzTOcOVdZF-th7BS_GYGguAS +[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 diff --git a/mkdocs.yml b/mkdocs.yml index 01c59caaa..6c57618ae 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -58,7 +58,8 @@ pages: - 'Browser Enhancements': 'topics/browser-enhancements.md' - 'The Browsable API': 'topics/browsable-api.md' - 'REST, Hypermedia & HATEOAS': 'topics/rest-hypermedia-hateoas.md' - - 'Third Party Resources': 'topics/third-party-resources.md' + - 'Third Party Packages': 'topics/third-party-packages.md' + - 'Tutorials and Resources': 'topics/tutorials-and-resources.md' - 'Contributing to REST framework': 'topics/contributing.md' - 'Project management': 'topics/project-management.md' - '3.0 Announcement': 'topics/3.0-announcement.md' @@ -71,3 +72,4 @@ pages: - 'Mozilla Grant': 'topics/mozilla-grant.md' - 'Funding': 'topics/funding.md' - 'Release Notes': 'topics/release-notes.md' + - 'Jobs': 'topics/jobs.md' diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 80e384c22..94c37321f 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -1290,6 +1290,15 @@ class ModelSerializer(Serializer): kwargs['read_only'] = True extra_kwargs[field_name] = kwargs + else: + # Guard against the possible misspelling `readonly_fields` (used + # by the Django admin and others). + assert not hasattr(self.Meta, 'readonly_fields'), ( + 'Serializer `%s.%s` has field `readonly_fields`; ' + 'the correct spelling for the option is `read_only_fields`.' % + (self.__class__.__module__, self.__class__.__name__) + ) + return extra_kwargs def get_uniqueness_extra_kwargs(self, field_names, declared_fields, extra_kwargs): diff --git a/tests/test_model_serializer.py b/tests/test_model_serializer.py index b839f56ca..cfa671125 100644 --- a/tests/test_model_serializer.py +++ b/tests/test_model_serializer.py @@ -10,6 +10,7 @@ from __future__ import unicode_literals import decimal from collections import OrderedDict +import pytest from django.core.exceptions import ImproperlyConfigured from django.core.validators import ( MaxValueValidator, MinLengthValidator, MinValueValidator @@ -1064,3 +1065,18 @@ class Issue3674Test(TestCase): child_expected = {'parent': 1, 'value': 'def'} self.assertEqual(child_serializer.data, child_expected) + + +class Issue4897TestCase(TestCase): + def test_should_assert_if_writing_readonly_fields(self): + class TestSerializer(serializers.ModelSerializer): + class Meta: + model = OneFieldModel + fields = ('char_field',) + readonly_fields = fields + + obj = OneFieldModel.objects.create(char_field='abc') + + with pytest.raises(AssertionError) as cm: + TestSerializer(obj).fields + cm.match(r'readonly_fields')