improve backward compatibility

by using date's class contructor instead of fromisostring
This commit is contained in:
B4rtware 2020-02-15 13:51:11 +01:00
parent a61ee3f03d
commit 3dcdc01cd1
No known key found for this signature in database
GPG Key ID: 4D0752B5285F629A

View File

@ -41,7 +41,7 @@ class MyModelSerializerWithMethod(serializers.ModelSerializer):
fields = "__all__" fields = "__all__"
def get_days_since_last_edit(self, obj): def get_days_since_last_edit(self, obj):
now = datetime.date.fromisoformat("2020-01-08") now = datetime.date(2020, 1, 8)
return (now - obj.last_edited).days return (now - obj.last_edited).days
@ -231,7 +231,7 @@ def test_perform_mutate_success():
mock_info(), mock_info(),
**{ **{
"cool_name": "Narf", "cool_name": "Narf",
"last_edited": datetime.date.fromisoformat("2020-01-04"), "last_edited": datetime.date(2020, 1, 4),
} }
) )