Dj-stripe: error in initial migrations: ValueError: SQLite backend does not support timezone-aware datetimes when USE_TZ is False

Created on 1 Nov 2017  路  3Comments  路  Source: dj-stripe/dj-stripe

When migrating i get the following error
Django==1.11.6
dj-stripe====1.0.0.post1
`
Operations to perform:
Apply all migrations: djstripe
Running migrations:
Applying djstripe.0008_auto_20150806_1641_squashed_0031_auto_20170606_1708...Traceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(args, *cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute
output = self.handle(args, *options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 87, in database_forwards
field,
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/schema.py", line 238, in add_field
self._remake_table(model, create_field=field)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/schema.py", line 113, in _remake_table
self.effective_default(create_field)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 229, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 770, in get_db_prep_save
prepared=False)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 1460, in get_db_prep_value
return connection.ops.adapt_datetimefield_value(value)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/operations.py", line 181, in adapt_datetimefield_value
raise ValueError("SQLite backend does not support timezone-aware datetimes when USE_TZ is False.")
ValueError: SQLite backend does not support timezone-aware datetimes when USE_TZ is False.

`

Most helpful comment

Please set USE_TZ to True then. sqlite isn't a good production database anyway, you should probably use Postgres.

All 3 comments

Please set USE_TZ to True then. sqlite isn't a good production database anyway, you should probably use Postgres.

Yes setting USE_TZ to true solved this.

Thank you for the quick response.

As for the database, we are using sqlite in the test env. to test the functionality will be postgres in prod.

@skjortan23 I'd suggest using postgres both locally and on production. You'll find yourself running into a bunch of issues locally that aren't on production and vice versa. Also, you'll miss out on the postgres-specific django fields (which we use)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbaragiola picture mbaragiola  路  4Comments

isaac-jordan picture isaac-jordan  路  4Comments

radyz picture radyz  路  6Comments

therefromhere picture therefromhere  路  4Comments

allthetime picture allthetime  路  7Comments