diff --git a/django_extensions/management/commands/admin_generator.py b/django_extensions/management/commands/admin_generator.py
index <HASH>..<HASH> 100644
--- a/django_extensions/management/commands/admin_generator.py
+++ b/django_extensions/management/commands/admin_generator.py
@@ -166,7 +166,8 @@ class AdminModel(UnicodeMixin):
     def _process_many_to_many(self, meta):
         raw_id_threshold = self.raw_id_threshold
         for field in meta.local_many_to_many:
-            related_objects = field.related.parent_model.objects.all()
+            related_model = getattr(field.related, 'related_model', field.related.model)
+            related_objects = related_model.objects.all()
             if(related_objects[:raw_id_threshold].count() < raw_id_threshold):
                 yield field.name
 
@@ -181,7 +182,8 @@ class AdminModel(UnicodeMixin):
         raw_id_threshold = self.raw_id_threshold
         list_filter_threshold = self.list_filter_threshold
         max_count = max(list_filter_threshold, raw_id_threshold)
-        related_count = field.related.parent_model.objects.all()
+        related_model = getattr(field.related, 'related_model', field.related.model)
+        related_count = related_model.objects.all()
         related_count = related_count[:max_count].count()
 
         if related_count >= raw_id_threshold:
Fixed issue with Django <I>