apply distinct to edition lookup

pull/1/head
eric 2013-07-26 19:51:45 -04:00
parent ecc75ee0ad
commit da9fc648e3
1 changed files with 12 additions and 0 deletions

View File

@ -34,6 +34,18 @@ class EditionLookup(ModelLookup):
search_fields = ('title__icontains',)
filters = {'ebooks__isnull': False, }
def get_query(self, request, term):
return super(EditionLookup, self).get_query(request, term).distinct()
def get_item(self, value):
item = None
if value:
try:
item = Edition.objects.get(pk=value)
except (ValueError, Edition.DoesNotExist):
item = None
return item
registry.register(OwnerLookup)
registry.register(WorkLookup)
registry.register(PublisherNameLookup)