Skip to content

Commit

Permalink
use aware DateTime object for initialization, since USE_TZ = True by …
Browse files Browse the repository at this point in the history
…default
  • Loading branch information
igorkramaric committed May 15, 2024
1 parent 501755d commit 0b2f5ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
psycopg[binary]==3.1.12
Django==5.0.6
Pillow==9.0.1
Pillow==10.3.0
4 changes: 2 additions & 2 deletions test_project/test_app/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, date
from datetime import datetime, date, timezone
from decimal import Decimal

from django.db import models
Expand All @@ -13,7 +13,7 @@ class MyModel(models.Model):

sensitive_field1 = models.CharField(max_length=25, default='sensitive')

datetime_field = models.DateTimeField(default=datetime(2011, 1, 11, 11, 11, 11))
datetime_field = models.DateTimeField(default=datetime(2011, 1, 11, 11, 11, 11, tzinfo=timezone.utc))
date_field = models.DateField(default=date(2011, 1, 11))

decimal_field = models.DecimalField(max_digits=10, decimal_places=2, default=Decimal('32.25'))
Expand Down
2 changes: 1 addition & 1 deletion test_project/test_app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_basic_serialization(self):
"null_field": None,
"decimal_field": 32.25,
"foreign_key": 1,
"datetime_field": "2011-01-11T11:11:11",
"datetime_field": "2011-01-11T11:11:11+00:00",
"image_field": "images/image_file.wbm",
"date_field": "2011-01-11",
"id": 1,
Expand Down

0 comments on commit 0b2f5ad

Please sign in to comment.