code: def get_all_related_many_to_many_objects(opts):
      
      if django.VERSION < (1, 9):
          return opts.get_all_related_many_to_many_objects()
      else:
          return [r for r in opts.related_objects if r.field.many_to_many]
docs: Django 1.8 changed meta api, see docstr in compat.get_all_related_objects()
  
      :param opts: Options instance
      :return: list of many-to-many relations