diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py index 546b9e57..5cb78363 100644 --- a/rest_framework_json_api/serializers.py +++ b/rest_framework_json_api/serializers.py @@ -13,8 +13,10 @@ class ResourceIdentifierObjectSerializer(BaseSerializer): 'incorrect_type': _('Incorrect type. Expected pk value, received {data_type}.'), } + model_class = None + def __init__(self, *args, **kwargs): - self.model_class = kwargs.pop('model_class', None) + self.model_class = kwargs.pop('model_class', self.model_class) if 'instance' not in kwargs and not self.model_class: raise RuntimeError('ResourceIdentifierObjectsSerializer must be initialized with a model class.') super(ResourceIdentifierObjectSerializer, self).__init__(*args, **kwargs)