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

fix(dumpscript): make_aware should not be called if aware already #1745

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Jul 15, 2022

Otherwise it raises a ValueError:

  File "…/django_extensions/management/commands/dumpscript.py", line 696, in get_attribute_value
    item_locator = orm_item_locator(value)
  File "…/django_extensions/management/commands/dumpscript.py", line 73, in orm_item_locator
    v = timezone.make_aware(v)
  File "…/django/utils/timezone.py", line 279, in make_aware
    raise ValueError("make_aware expects a naive datetime, got %s" % value)
ValueError: make_aware expects a naive datetime, got 2022-05-19 06:53:06.476209+00:00

value being a user's last_login field.

The project uses USE_TZ = True.

The check is there since Django 1.8 already:
django/django@fa89acf

Otherwise it raises a ValueError:

```
  File "…/django_extensions/management/commands/dumpscript.py", line 696, in get_attribute_value
    item_locator = orm_item_locator(value)
  File "…/django_extensions/management/commands/dumpscript.py", line 73, in orm_item_locator
    v = timezone.make_aware(v)
  File "…/django/utils/timezone.py", line 279, in make_aware
    raise ValueError("make_aware expects a naive datetime, got %s" % value)
ValueError: make_aware expects a naive datetime, got 2022-05-19 06:53:06.476209+00:00
```

`value` being a user's `last_login` field.

The project uses `USE_TZ = True`.

The check is there since Django 1.8 already:
django/django@fa89acf
@trbs trbs merged commit 29b7530 into django-extensions:main Sep 9, 2022
@trbs
Copy link
Member

trbs commented Sep 9, 2022

Thanks !

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

Successfully merging this pull request may close these issues.

None yet

2 participants