Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Metaclass compatablity with python 3

  • Loading branch information...
commit 2f121a3992e472ef82db7a7cbe882464b6f27051 1 parent c6d60ab
Mike Fogel authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 timezone_field/fields.py
12 timezone_field/fields.py
View
@@ -6,7 +6,7 @@
from django.utils.encoding import smart_text
-class TimeZoneField(models.Field):
+class TimeZoneFieldBase(models.Field):
"""
Provides database store for pytz timezone objects.
@@ -33,8 +33,6 @@ class TimeZoneField(models.Field):
description = "A pytz timezone object"
- __metaclass__ = models.SubfieldBase
-
CHOICES = [(pytz.timezone(tz), tz) for tz in pytz.all_timezones]
MAX_LENGTH = 63
@@ -44,7 +42,7 @@ def __init__(self, **kwargs):
'choices': TimeZoneField.CHOICES,
}
defaults.update(kwargs)
- super(TimeZoneField, self).__init__(**defaults)
+ super(TimeZoneFieldBase, self).__init__(**defaults)
def get_internal_type(self):
return 'CharField'
@@ -71,6 +69,12 @@ def _get_python_and_db_repr(self, value):
raise ValidationError("Invalid timezone '%s'" % value)
+# http://packages.python.org/six/#six.with_metaclass
+class TimeZoneField(six.with_metaclass(models.SubfieldBase,
+ TimeZoneFieldBase)):
+ pass
+
+
# South support
try:
from south.modelsinspector import add_introspection_rules
Please sign in to comment.
Something went wrong with that request. Please try again.