diff --git a/rest_framework/utils/model_meta.py b/rest_framework/utils/model_meta.py index 8eb00e4334..77952fbf89 100644 --- a/rest_framework/utils/model_meta.py +++ b/rest_framework/utils/model_meta.py @@ -92,7 +92,7 @@ def _get_fields(opts): def _get_to_field(field): - return field.to_fields[0] if field.to_fields else None + return getattr(field, 'to_fields', None) and field.to_fields[0] def _get_forward_relationships(opts):