Skip to content

Commit a0d1c89

Browse files
Fixed tests to pass for all versions of Django. Updated documentation.
1 parent bf86207 commit a0d1c89

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

docs/fields.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ TimeZoneField
1313
.. |datetime.tzinfo| replace:: ``datetime.tzinfo``
1414
.. _datetime.tzinfo: https://docs.python.org/2/library/datetime.html#tzinfo-objects
1515

16+
.. |datetime.datetime| replace:: ``datetime.datetime``
17+
.. _datetime.datetime: https://docs.python.org/2/library/datetime.html#datetime-objects
18+
1619
.. |models.CharField| replace:: ``models.CharField``
1720
.. _models.CharField: https://docs.djangoproject.com/en/dev/ref/models/fields/#charfield
1821

@@ -105,8 +108,13 @@ LinkedTZDateTimeField
105108
the timezone or a string (if the timezone field is
106109
located on the model).
107110
:param time_override: Automatically overrides the time value each time the
108-
object is saved to the time that is declared.Must be a
109-
|datetime.time|_ instance.
111+
object is saved to the time that is declared. Must be
112+
a |datetime.time|_ instance.
113+
:raises AttributeError: if the ``populate_from`` parameter is invalid.
114+
:raises ValueError: if the ``time_override`` is not a |datetime.time|_ instance.
115+
:raises pytz.UnknownTimeZoneError: if the parsed model instance value of ``populate_from`` is not a valid Olson time zone string.
116+
:return: A |datetime.datetime|_ object based on the time zone declared in ``populate_from`` and override from ``time_override`` or |None|_.
117+
:rtype: |datetime.datetime|_
110118

111119
.. note:: If ``auto_now`` or ``auto_now_add`` is declared, the value of ``time_override`` is ignored.
112120
.. caution:: `Django cannot serialize lambdas! <https://docs.djangoproject.com/en/1.7/ref/models/fields/#default>`_

tests/test_invalid_timezonefield.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,5 @@ def test_location_max_length(self):
2424
)
2525

2626
def test_bad_location_default_string(self):
27-
with self.assertRaisesMessage(
28-
expected_exception=ValidationError,
29-
expected_message="'Bad/Worse' is not a valid time zone."
30-
):
27+
with self.assertRaises(ValidationError):
3128
TZWithBadStringDefault.objects.create()

0 commit comments

Comments
 (0)