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

Seeding datetime objects fails due to Django 5.0 deprecating the is_dst argument to timezone.make_aware #119

Open
offbyone opened this issue Dec 11, 2023 · 4 comments

Comments

@offbyone
Copy link

offbyone commented Dec 11, 2023

The is_dst argument to make_aware() is deprecated as of Django 5.0: https://docs.djangoproject.com/en/dev/internals/deprecation/#deprecation-removed-in-5-0

Running manage.py seed on an application with DateTimeField in the models results in this:

/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py:1654: RuntimeWarning: DateTimeField ElectionState.valid_from received a naive datetime (2023-12-11 07:14:28.937317) while time zone support is active.
  warnings.warn(
Traceback (most recent call last):
  File "/Users/offby1/projects/worldcon/nomnom/manage.py", line 22, in <module>
    main()
  File "/Users/offby1/projects/worldcon/nomnom/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 639, in handle
    app_output = self.handle_app_config(app_config, **options)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/management/commands/seed.py", line 63, in handle_app_config
    generated = seeder.execute()
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/seeder.py", line 250, in execute
    executed_entity = entity.execute(using, inserted_entities)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/seeder.py", line 157, in execute
    faker_data = {
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/seeder.py", line 158, in <dictcomp>
    field: format_field(field_format, inserted_entities)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/seeder.py", line 144, in format_field
    return format(inserted_entities)
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/guessers.py", line 120, in <lambda>
    return lambda x: _timezone_format(faker.date_time())
  File "/Users/offby1/projects/worldcon/nomnom/.venv/lib/python3.10/site-packages/django_seed/guessers.py", line 21, in _timezone_format
    return timezone.make_aware(value, timezone.get_current_timezone(), is_dst=False)
TypeError: make_aware() got an unexpected keyword argument 'is_dst'
@mantertius
Copy link

I was trying to create a seed to models with DateTimeField and encountered the same issue . Using Django==5.0.1 and django-seed==0.3.1

@Omkar-Jawalkar
Copy link

Is there any fix around this?

@salimbyte
Copy link

Is there any fix around this?

in the settings.py set
USE_TZ = False

the error occurs when it tries to generates a timezone aware datetime if the 'USE_TZ' setting is enabled

@krv006
Copy link

krv006 commented Oct 25, 2024

in the project settings.py set USE_TZ = False and also install django==5.0.1 version (django-seed=0.3.1)

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

5 participants