1. Denis Kolodin
  2. DjangoGo

Commits

Denis Kolodin  committed 7b638c6

Get item by index for Choices.

  • Participants
  • Parent commits 2b0451f
  • Branches default

Comments (0)

Files changed (1)

File src/djangogo/choices.py

View file
         if key in self.maps:
             return self.maps[key]
         raise AttributeError("There isn't '{0}' in choices.".format(key))
+
+    #----------------------------------------------------------------------
+    def __getitem__(self, key):
+        if key in self.maps:
+            return self.maps[key]
+        raise IndexError("There isn't '{0}' in choices.".format(key))
     
     #----------------------------------------------------------------------
     def __contains__(self, key):