Skip to content

Commit ccdcef5

Browse files
committed
Dropping the blank == null hookiness
1 parent 5b42933 commit ccdcef5

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

timezone_field/fields.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ class TimeZoneField(models.CharField):
1515
None # if blank == True
1616
pytz.tzinfo.DstTzInfo # an instance of
1717
18-
The 'null' kwarg is tied directly to 'blank'.
19-
If you accept blanks, they will be stored in the DB as null's.
20-
If you don't accept blanks, the db will be statically typed
21-
with NOT NULL.
22-
2318
If you choose to add validators at runtime, they need to accept
2419
pytz.tzinfo objects as input.
2520
"""
@@ -31,17 +26,10 @@ class TimeZoneField(models.CharField):
3126
CHOICES = tuple(zip(pytz.all_timezones, pytz.all_timezones))
3227
MAX_LENGTH = 63
3328

34-
def __init__(self, blank=False, validators=[], **kwargs):
35-
# We're not storing strings, we're storing objects.
36-
# Tie blank and DB null's together directly.
37-
if 'null' in kwargs:
38-
raise TypeError("'null' is an invalid keyword argument")
39-
29+
def __init__(self, validators=[], **kwargs):
4030
defaults = {
4131
'max_length': TimeZoneField.MAX_LENGTH,
4232
'choices': TimeZoneField.CHOICES,
43-
'blank': blank,
44-
'null': blank,
4533
}
4634
defaults.update(kwargs)
4735

timezone_field/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class TestModel(models.Model):
1717
tz_not_blank = TimeZoneField()
18-
tz_blank = TimeZoneField(blank=True)
18+
tz_blank = TimeZoneField(blank=True, null=True)
1919

2020

2121
class TestModelForm(forms.ModelForm):

0 commit comments

Comments
 (0)