@@ -237,7 +237,16 @@ def get_related_resource_type(relation):
237
237
else :
238
238
relation_model = parent_model_relation .related .model
239
239
elif parent_model_relation_type is ManyToManyDescriptor :
240
- relation_model = parent_model_relation .field .remote_field .model
240
+ if django .VERSION >= (1 , 9 ):
241
+ relation_model = parent_model_relation .field .remote_field .model
242
+ # In case we are in a reverse relation
243
+ if relation_model == parent_model :
244
+ relation_model = parent_model_relation .field .model
245
+ elif django .VERSION >= (1 , 8 ):
246
+ relation_model = parent_model_relation .related .model
247
+ # In case we are in a reverse relation
248
+ if relation_model == parent_model :
249
+ relation_model = parent_model_relation .related .related_model
241
250
elif parent_model_relation_type is ReverseManyRelatedObjectsDescriptor :
242
251
relation_model = parent_model_relation .field .related .model
243
252
elif parent_model_relation_type is ReverseGenericManyToOneDescriptor :
0 commit comments