Skip to content

Commit 8d1afae

Browse files
Corrected documentation
Documentation was incorrect, and would cause errors in Django 1.7 when it came time to create migrations.
1 parent 84c7901 commit 8d1afae

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

README.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ Imagine you have the models ``Location`` and ``LocationReportingPeriod``:
9898
)
9999
100100
101+
def _get_reporting_period_timzone(obj):
102+
"""Called as `obj` being the LocationReportingPeriodInstance.
103+
104+
Note:
105+
populate_from=lambda: instance: instance.location.timezone is not valid.
106+
107+
"""
108+
return obj.location.timezone
109+
101110
class LocationReportingPeriod(models.Model)
102111
location = models.ForeignKey(
103112
verbose_name=_('location'),
@@ -108,15 +117,15 @@ Imagine you have the models ``Location`` and ``LocationReportingPeriod``:
108117
verbose_name=_('start'),
109118
# populate_from can also be a string value, provided that the string value
110119
# is a field on the same model
111-
populate_from=lambda instance: instance.location.timezone,
120+
populate_from=_get_reporting_period_timzone,
112121
# Time override must be a datetime.time instance
113-
time_override=datetime.min.time,
122+
time_override=datetime.min.time(),
114123
)
115124
end = LinkedTZDateTimeField(
116125
verbose_name=_('end'),
117-
populate_from=lambda instance: instance.location.timezone,
126+
populate_from=_get_reporting_period_timzone,
118127
# Time override must be a datetime.time instance
119-
time_override=datetime.max.time,
128+
time_override=datetime.max.time(),
120129
)
121130
122131
created = LinkedTZDateTimeField(
@@ -244,10 +253,6 @@ Contributors
244253
Changelog
245254
---------
246255

256+
- 0.3 Code cleanup.
247257
- 0.2 Multiple bug fixes based on testing.
248258
- 0.1 Initial release.
249-
250-
License
251-
=======
252-
253-
The MIT License.

0 commit comments

Comments
 (0)