mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #12524 -- Clarified handling of pre-1000AD dates in datetime_safe (and thus, the serializers). Patch includes moving the datetime_safe tests into the utils regressiontests module. Thanks to gsf for the report and initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12423 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -277,6 +277,21 @@ None
|
||||
>>> print obj
|
||||
<DeserializedObject: serializers.Player(pk=1)>
|
||||
|
||||
# Regression for #12524 -- dates before 1000AD get prefixed 0's on the year
|
||||
>>> a = Article.objects.create(
|
||||
... pk=4,
|
||||
... author = jane,
|
||||
... headline = "Nobody remembers the early years",
|
||||
... pub_date = datetime(1, 2, 3, 4, 5, 6))
|
||||
|
||||
>>> serialized = serializers.serialize("json", [a])
|
||||
>>> print serialized
|
||||
[{"pk": 4, "model": "serializers.article", "fields": {"headline": "Nobody remembers the early years", "pub_date": "0001-02-03 04:05:06", "categories": [], "author": 2}}]
|
||||
|
||||
>>> obj = list(serializers.deserialize("json", serialized))[0]
|
||||
>>> print obj.object.pub_date
|
||||
0001-02-03 04:05:06
|
||||
|
||||
"""}
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user