diff options
Diffstat (limited to 'ishtar_common/lookups.py')
| -rw-r--r-- | ishtar_common/lookups.py | 23 | 
1 files changed, 20 insertions, 3 deletions
diff --git a/ishtar_common/lookups.py b/ishtar_common/lookups.py index e2e9251e7..3481ba1a9 100644 --- a/ishtar_common/lookups.py +++ b/ishtar_common/lookups.py @@ -15,10 +15,27 @@ class LookupChannel(BaseLookupChannel):                  ids.append(item.pk)              else:                  ids.append(item) -        return super(LookupChannel, self).get_objects(ids) + +        # TODO: strange bug on Import edit +        # copied from lookup_channel.py +        if getattr(self.model._meta.pk, "remote_field", False): +            # Use the type of the field being referenced (2.0+) +            # modification is here +            # pk_type = self.model._meta.pk.remote_field.field.to_python +            pk_type = int +        elif getattr(self.model._meta.pk, "rel", False): +            # Use the type of the field being referenced +            pk_type = self.model._meta.pk.rel.field.to_python +        else: +            pk_type = self.model._meta.pk.to_python + +        # Return objects in the same order as passed in here +        ids = [pk_type(pk) for pk in ids] +        things = self.model.objects.in_bulk(ids) +        return [things[aid] for aid in ids if aid in things]      def format_item_display(self, item): -        return u"<span class='ajax-label'>%s</span>" % str(item) +        return "<span class='ajax-label'>%s</span>" % str(item)  class TypeLookupChannel(LookupChannel): @@ -118,7 +135,7 @@ class UserLookup(LookupChannel):          return self.model.objects.filter(query).order_by('person__name')[:20]      def format_item_display(self, item): -        return u"<span class='ajax-label'>%s</span>" % str(item.person) +        return "<span class='ajax-label'>%s</span>" % str(item.person)  @register('area')  | 
