Skip to content

Commit 2b99b79

Browse files
committed
South support
Thansks to github.com/sidmitra https://github.com/brosner/django-timezones/pull/13/files
1 parent 0cb812b commit 2b99b79

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

timezone_field/fields.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ class TimeZoneField(models.CharField):
1818
__metaclass__ = models.SubfieldBase
1919

2020
CHOICES = tuple(zip(pytz.all_timezones, pytz.all_timezones))
21+
MAX_LENGTH = 63
2122

2223
def __init__(self, validators=[], **kwargs):
2324
defaults = {
24-
'max_length': 63,
25+
'max_length': TimeZoneField.MAX_LENGTH,
2526
'choices': TimeZoneField.CHOICES,
2627
}
2728
defaults.update(kwargs)
@@ -75,3 +76,23 @@ def get_prep_value(self, value):
7576

7677
def value_to_string(self, value):
7778
return self.get_prep_value(value)
79+
80+
81+
# South support
82+
try:
83+
from south.modelsinspector import add_introspection_rules
84+
except ImportError:
85+
pass
86+
else:
87+
add_introspection_rules(
88+
rules=[(
89+
(TimeZoneField, ), # Class(es) these apply to
90+
[], # Positional arguments (not used)
91+
{ # Keyword argument
92+
'max_length': [
93+
'max_length', { 'default': TimeZoneField.MAX_LENGTH }
94+
],
95+
}
96+
)],
97+
patterns=['timezones\.fields\.']
98+
)

0 commit comments

Comments
 (0)