Skip to content

Commit

Permalink
Add py3 unicode support.
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesfabio committed Mar 25, 2015
1 parent 8141371 commit 6c2ae8a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions separatedvaluesfield/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.forms.fields import MultipleChoiceField
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core import validators
from django.db import models
from django.core import exceptions
from django.db import models
from django.forms.fields import MultipleChoiceField
from django.utils.text import capfirst


Expand Down Expand Up @@ -31,7 +34,7 @@ def validate(self, value, model_instance):

# If we have integers, convert them first to be sure we only compare
# right types
choices = [unicode(choice) for choice in choices]
choices = ['%s' % choice for choice in choices]

for val in value:
if val and not val in choices:
Expand All @@ -58,7 +61,7 @@ def get_db_prep_value(self, value, **kwargs):

assert(isinstance(value, list) or isinstance(value, tuple))

return self.token.join([unicode(s) for s in value])
return self.token.join(['%s' % s for s in value])

def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
Expand Down

0 comments on commit 6c2ae8a

Please sign in to comment.