django-seed
django-seed copied to clipboard
Seeding datetime objects fails due to Django 5.0 deprecating the `is_dst` argument to `timezone.make_aware`
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'
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
Is there any fix around this?
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
in the project settings.py set USE_TZ = False and also install django==5.0.1 version (django-seed=0.3.1)
Does anyone have a solution for projects which require USE_TZ=True?
This seems to fix it https://github.com/Brobin/django-seed/pull/120