Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix some of the python 3 errors

  • Loading branch information...
commit c6d60abd7ad1a67b91a922e393b6f596a324a221 1 parent b9dcd22
Mike Fogel authored
Showing with 6 additions and 4 deletions.
  1. +4 −3 timezone_field/fields.py
  2. +2 −1  timezone_field/tests.py
7 timezone_field/fields.py
View
@@ -2,7 +2,8 @@
from django.core.exceptions import ValidationError
from django.db import models
-from django.utils.encoding import smart_unicode
+from django.utils import six
+from django.utils.encoding import smart_text
class TimeZoneField(models.Field):
@@ -61,8 +62,8 @@ def _get_python_and_db_repr(self, value):
if value is None or value == '':
return (None, None)
if value is pytz.UTC or isinstance(value, pytz.tzinfo.BaseTzInfo):
- return (value, smart_unicode(value))
- if isinstance(value, basestring):
+ return (value, smart_text(value))
+ if isinstance(value, six.string_types):
try:
return (pytz.timezone(value), value)
except pytz.UnknownTimeZoneError:
3  timezone_field/tests.py
View
@@ -4,6 +4,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.test import TestCase
+from django.utils import six
from . import TimeZoneField, TimeZoneFormField
@@ -61,7 +62,7 @@ def test_valid_with_defaults(self):
# http://stackoverflow.com/questions/7399490/
data = dict(
(field_name, field.initial)
- for field_name, field in TestModelForm().fields.iteritems()
+ for field_name, field in six.iteritems(TestModelForm().fields)
)
data.update({'tz': GMT})
form = TestModelForm(data=data)
Please sign in to comment.
Something went wrong with that request. Please try again.