papermerge icon indicating copy to clipboard operation
papermerge copied to clipboard

Migration from SQLite to MariaDB give an AttributeError: 'str' object has no attribute 'tzinfo'

Open amo13 opened this issue 5 years ago • 2 comments

I converted my SQLite database file to mariadb format using the rebasedata tool. I then created the papermerge user and database and imported the converted database into mariadb. I changed the configuration of papermerge and got an error after trying to start papermerge. Running manage.py migrate gives more insight into the issue:

System check identified some issues:

WARNINGS:
core.Document.digest: (mysql.W003) MariaDB may not allow unique CharFields to have a max_length > 255.
	HINT: See: https://docs.djangoproject.com/en/3.1/ref/databases/#mysql-character-fields
Traceback (most recent call last):
  File "/usr/bin/django-admin", line 33, in <module>
    sys.exit(load_entry_point('Django==3.1.3', 'console_scripts', 'django-admin')())
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 92, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/lib/python3.9/site-packages/django/db/migrations/loader.py", line 53, in __init__
    self.build_graph()
  File "/usr/lib/python3.9/site-packages/django/db/migrations/loader.py", line 216, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/usr/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 78, in applied_migrations
    return {(migration.app, migration.name): migration for migration in self.migration_qs}
  File "/usr/lib/python3.9/site-packages/django/db/models/query.py", line 287, in __iter__
    self._fetch_all()
  File "/usr/lib/python3.9/site-packages/django/db/models/query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/lib/python3.9/site-packages/django/db/models/query.py", line 70, in __iter__
    for row in compiler.results_iter(results):
  File "/usr/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1100, in apply_converters
    value = converter(value, expression, connection)
  File "/usr/lib/python3.9/site-packages/django/db/backends/mysql/operations.py", line 310, in convert_datetimefield_value
    value = timezone.make_aware(value, self.connection.timezone)
  File "/usr/lib/python3.9/site-packages/django/utils/timezone.py", line 234, in make_aware
    return timezone.localize(value, is_dst=is_dst)
  File "/usr/lib/python3.9/site-packages/pytz/__init__.py", line 233, in localize
    if dt.tzinfo is not None:
AttributeError: 'str' object has no attribute 'tzinfo'

Info:

  • OS: Arch Linux
  • Database: MariaDB 10.5.8
  • Papermerge Version: 1.5.3

amo13 avatar Dec 04 '20 15:12 amo13

@amo13, thanks for reporting this issue! Looks like a simple fix.

ciur avatar Dec 04 '20 17:12 ciur

now with mysql, still it happens

william0353 avatar Aug 26 '21 14:08 william0353