mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 13:00:12 +03:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d793d02cfc
|
@ -26,9 +26,10 @@ The initial aim is to provide a single full-time position on REST framework.
|
|||
<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>
|
||||
</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/), 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/).*
|
||||
|
||||
---
|
||||
|
||||
|
|
BIN
docs/img/premium/micropyramid-readme.png
Normal file
BIN
docs/img/premium/micropyramid-readme.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -76,10 +76,11 @@ The initial aim is to provide a single full-time position on REST framework.
|
|||
<li><a href="https://getstream.io/try-the-api/?utm_source=drf&utm_medium=banner&utm_campaign=drf" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/stream-130.png)">Stream</a></li>
|
||||
<li><a href="https://hello.machinalis.co.uk/" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/Machinalis130.png)">Machinalis</a></li>
|
||||
<li><a href="https://rollbar.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/rollbar.png)">Rollbar</a></li>
|
||||
<li><a href="https://micropyramid.com/django-rest-framework-development-services/" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/mp-text-logo.png)">MicroPyramid</a></li>
|
||||
</ul>
|
||||
<div style="clear: both; padding-bottom: 20px;"></div>
|
||||
|
||||
*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/).*
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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')
|
||||
|
|
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.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
|
||||
|
|
Loading…
Reference in New Issue
Block a user