Skip to content

Commit

Permalink
found a very simple way without the need to hack the related manager:…
Browse files Browse the repository at this point in the history
… Simply get a "fresh" model manager.

See also: etianen/django-reversion#153 (comment)
  • Loading branch information
jedie committed May 10, 2012
1 parent 0a14667 commit bf408d8
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions reversion_compare/admin.py
Expand Up @@ -93,19 +93,10 @@ def get_many_to_many(self):
"""
returns a queryset with all many2many objects
"""
if self.field.get_internal_type() != "ManyToManyField": # FIXME!
return
many_related_manager = self.get_related()
if many_related_manager:
# XXX: work-a-round to get all objects, see: https://github.com/etianen/django-reversion/issues/153
old_core_filters = many_related_manager.core_filters
many_related_manager.core_filters = {} # disable the pre filtering

ids = self.value
queryset = many_related_manager.all().filter(pk__in=ids)

many_related_manager.core_filters = old_core_filters # restore core_filters

if self.field.get_internal_type() == "ManyToManyField": # FIXME!
ids = self.value # is: version.field_dict[field.name]
related_model = self.field.rel.to
queryset = related_model.objects.all().filter(pk__in=ids)
return queryset

def debug(self):
Expand Down

0 comments on commit bf408d8

Please sign in to comment.