Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving an instance stores the timezone and applies it to all read operations #20

Open
deceze opened this issue Aug 25, 2022 · 1 comment

Comments

@deceze
Copy link

deceze commented Aug 25, 2022

LinkedTZDateTimeField.pre_save calls _convert_value which calls _get_populate_from which does self.timezone = tz. Now the timezone used to save the instance is stored "statically" in the field.

Reading records from the database uses:

def to_python(self, value):
    """Convert the value to the appropriate timezone."""
    # pylint: disable=newstyle
    value = super(LinkedTZDateTimeField, self).to_python(value)

    if not value:
        return value

    return value.astimezone(self.timezone)  # 👈

So the timezone of the last saved instance is applied to all read instances, even if they may have other timezones.

@pjrulez
Copy link

pjrulez commented Nov 3, 2024

Is there an alternative maintained package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants