Commits

Denis Kolodin committed 7b638c6

Get item by index for Choices.

Comments (0)

Files changed (1)

src/djangogo/choices.py

         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):