1. Bernardo Pires
  2. django-selectable


Bernardo Pires  committed e0f108e Draft

get_item now uses the direct get method from a method and no longer calls get_queryset as the query on a primary key will always select maximum 1 element

  • Participants
  • Parent commits c1af6c9
  • Branches default

Comments (0)

Files changed (1)

File selectable/base.py

View file
         item = None
         if value:
-                item = self.get_queryset().filter(pk=value)[0]
-            except IndexError:
+                item = self.model.objects.get(pk=value)
+            except self.model.DoesNotExist:
         return item