Skip to content

fernet_fields.EncryptedDateTimeField doesn’t save datetime timezone #29

@dk-WZFinTech

Description

@dk-WZFinTech

In model AccountTransaction as creation_timestamp we using fernet_fields.EncryptedDateTimeField. And we just found that this field is loosing timezone on save action.

Please see below code:

In [22]: at_z3 = AccountTransaction.objects.last()

In [22]: at_z3.creation_timestamp
Out[22]: datetime.datetime(2021, 10, 29, 3, 16, 6, 896068)

In [23]: at_z3.creation_timestamp = set_timezone(at_z3.creation_timestamp)

In [24]: at_z3.creation_timestamp
Out[24]: datetime.datetime(2021, 10, 29, 3, 16, 6, 896068, tzinfo=<DstTzInfo 'Europe/Berlin' CEST+2:00:00 DST>)

In [25]: at_z3.save()

In [26]: at_z4 = AccountTransaction.objects.last()

In [27]: at_z3
Out[27]: <AccountTransaction: f2d60076-ff91-4d98-8f63-7b2e896635e6-T613951385360465921.48974>

In [28]: at_z4
Out[28]: <AccountTransaction: f2d60076-ff91-4d98-8f63-7b2e896635e6-T613951385360465921.48974>

In [29]: at_z3.creation_timestamp
Out[29]: datetime.datetime(2021, 10, 29, 3, 16, 6, 896068, tzinfo=<DstTzInfo 'Europe/Berlin' CEST+2:00:00 DST>)

In [30]: at_z4.creation_timestamp
Out[30]: datetime.datetime(2021, 10, 29, 1, 16, 6, 896068)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions