mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Deprecations move into assertion errors
This commit is contained in:
parent
b44ab76d2c
commit
072442025c
|
@ -13,7 +13,6 @@ response content is handled by parsers and renderers.
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import DurationField as ModelDurationField
|
from django.db.models import DurationField as ModelDurationField
|
||||||
|
@ -1016,16 +1015,14 @@ class ModelSerializer(Serializer):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if fields is None and exclude is None:
|
assert not (fields is None and exclude is None), (
|
||||||
warnings.warn(
|
"Creating a ModelSerializer without either the 'fields' attribute "
|
||||||
"Creating a ModelSerializer without either the 'fields' "
|
"or the 'exclude' attribute has been deprecated since 3.3.0, "
|
||||||
"attribute or the 'exclude' attribute is deprecated "
|
"and is now disallowed. Add an explicit fields = '__all__' to the "
|
||||||
"since 3.3.0. Add an explicit fields = '__all__' to the "
|
"{serializer_class} serializer.".format(
|
||||||
"{serializer_class} serializer.".format(
|
serializer_class=self.__class__.__name__
|
||||||
serializer_class=self.__class__.__name__
|
),
|
||||||
),
|
)
|
||||||
DeprecationWarning
|
|
||||||
)
|
|
||||||
|
|
||||||
if fields == ALL_FIELDS:
|
if fields == ALL_FIELDS:
|
||||||
fields = None
|
fields = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user