diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index fa5e8eb77d..2279f71639 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -1241,7 +1241,7 @@ class Model(object): # Handles related many-to-many object retrieval. # Examples: Album.get_song(), Album.get_song_list(), Album.get_song_count() def _get_related_many_to_many(self, method_name, rel_class, rel_field, **kwargs): - kwargs['%s__%s__exact' % (rel_field.name, rel_class._meta.pk.name)] = getattr(self, rel_class._meta.pk.attname) + kwargs['%s__%s__exact' % (rel_field.name, self._meta.pk.name)] = getattr(self, self._meta.pk.attname) return getattr(rel_class._default_manager, method_name)(**kwargs) # Handles setting many-to-many related objects.