|  | 
| 7 | 7 | import inflection | 
| 8 | 8 | from django.db.models import Manager, QuerySet | 
| 9 | 9 | from django.utils import six, encoding | 
|  | 10 | +from django.conf import settings | 
| 10 | 11 | from rest_framework import relations | 
| 11 | 12 | from rest_framework import renderers | 
| 12 | 13 | from rest_framework.serializers import BaseSerializer, Serializer, ListSerializer | 
| @@ -387,9 +388,10 @@ def build_json_resource_obj(fields, resource, resource_instance, resource_name): | 
| 387 | 388 |             ('id', encoding.force_text(resource_instance.pk) if resource_instance else None), | 
| 388 | 389 |             ('attributes', JSONRenderer.extract_attributes(fields, resource)), | 
| 389 | 390 |         ] | 
| 390 |  | -        relationships = JSONRenderer.extract_relationships(fields, resource, resource_instance) | 
| 391 |  | -        if relationships: | 
| 392 |  | -            resource_data.append(('relationships', relationships)) | 
|  | 391 | +        if getattr(settings, 'JSON_API_IMPLICIT_RELATIONSHIPS', True): | 
|  | 392 | +            relationships = JSONRenderer.extract_relationships(fields, resource, resource_instance) | 
|  | 393 | +            if relationships: | 
|  | 394 | +                resource_data.append(('relationships', relationships)) | 
| 393 | 395 |         # Add 'self' link if field is present and valid | 
| 394 | 396 |         if api_settings.URL_FIELD_NAME in resource and \ | 
| 395 | 397 |                 isinstance(fields[api_settings.URL_FIELD_NAME], relations.RelatedField): | 
|  | 
0 commit comments