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 df22c1e36..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/).* --- 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') diff --git a/tox.ini b/tox.ini index abe045e15..b1be1a83c 100644 --- a/tox.ini +++ b/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.11a1,<2.0 + django111: Django>=1.11b1,<2.0 djangomaster: https://github.com/django/django/archive/master.tar.gz -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt