Skip to content

Commit

Permalink
Use with_metaclass for adding more py3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
thoas committed Mar 26, 2015
1 parent 3976099 commit 9b6bd20
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions separatedvaluesfield/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from django.forms.fields import MultipleChoiceField
from django.utils import six
from django.utils.text import capfirst
from django.utils.six import with_metaclass


class SeparatedValuesField(models.CharField):
__metaclass__ = models.SubfieldBase

class SeparatedValuesField(with_metaclass(models.SubfieldBase, models.CharField)):
def __init__(self, *args, **kwargs):
self.token = kwargs.pop('token', ',')
self.cast = kwargs.pop('cast', six.text_type)
Expand Down Expand Up @@ -39,7 +38,7 @@ def validate(self, value, model_instance):
choices = [self.cast(choice) for choice in choices]

for val in value:
if val and not val in choices:
if val and val not in choices:
raise exceptions.ValidationError(self.error_messages['invalid_choice'] % val)

if value is None and not self.null:
Expand Down

0 comments on commit 9b6bd20

Please sign in to comment.