From c6090e335fc79ceab562802b9334bf80588a339e Mon Sep 17 00:00:00 2001 From: Jean Luis Lopez Date: Wed, 5 Jun 2019 11:25:43 -0400 Subject: [PATCH] Add compatibility with Python3 --- README.md | 3 +++ chosen/fields.py | 2 +- chosen/forms.py | 6 ++---- chosen/widgets.py | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7d0b691..c388f77 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,11 @@ Installation The recommended way to install from source is with pip: + // Original repository only for Python 2 versions pip install -e "git+https://github.com/theatlantic/django-chosen.git#egg=django-chosen" + // This repository compatible with Python 3 + pip install git+https://github.com/Jeanluis019/django-chosen If the source is already checked out, use setuptools: python setup.py develop diff --git a/chosen/fields.py b/chosen/fields.py index c09b2c9..1a7d829 100644 --- a/chosen/fields.py +++ b/chosen/fields.py @@ -1,6 +1,6 @@ from django import forms -from widgets import ChosenSelect, ChosenSelectMultiple, ChosenGroupSelect +from chosen.widgets import ChosenSelect, ChosenSelectMultiple, ChosenGroupSelect __all__ = [ 'ChosenFieldMixin', 'ChosenChoiceField', 'ChosenMultipleChoiceField', diff --git a/chosen/forms.py b/chosen/forms.py index 49d65ab..aae805c 100644 --- a/chosen/forms.py +++ b/chosen/forms.py @@ -1,6 +1,4 @@ # flake8: noqa -import fields -from fields import * +from chosen.fields import * -import widgets -from widgets import * +from chosen.widgets import * diff --git a/chosen/widgets.py b/chosen/widgets.py index 0ea5743..94d5e59 100644 --- a/chosen/widgets.py +++ b/chosen/widgets.py @@ -30,10 +30,10 @@ def render(self, *args, **kwargs): def add_to_css_class(self, classes, new_class): new_classes = classes try: - classes_test = u" " + unicode(classes) + u" " - new_class_test = u" " + unicode(new_class) + u" " + classes_test = u" " + str(classes) + u" " + new_class_test = u" " + str(new_class) + u" " if new_class_test not in classes_test: - new_classes += u" " + unicode(new_class) + new_classes += u" " + str(new_class) except TypeError: pass return new_classes