mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-04-25 13:24:44 +00:00
Implement __contains__ ('x' in Choices('x')) for Choices objects.
In Choices, `_choice_dict` appears to be a definitive location of all internal/DB representations, so it seems the best target for finding out if the given item is part of the sequences.
This commit is contained in:
parent
369f9f8ced
commit
f89369f9ac
1 changed files with 4 additions and 0 deletions
|
|
@ -76,3 +76,7 @@ class Choices(object):
|
|||
def __repr__(self):
|
||||
return '%s(%s)' % (self.__class__.__name__,
|
||||
', '.join(("%s" % repr(i) for i in self._full)))
|
||||
|
||||
def __contains__(self, item):
|
||||
if item in self._choice_dict.values():
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in a new issue