[GH-ISSUE #242] Migration from SQLite to MariaDB give an AttributeError: 'str' object has no attribute 'tzinfo' #195

Closed
opened 2026-02-25 21:31:24 +03:00 by kerem · 2 comments
Owner

Originally created by @amo13 on GitHub (Dec 4, 2020).
Original GitHub issue: https://github.com/ciur/papermerge/issues/242

Originally assigned to: @ciur on GitHub.

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
Originally created by @amo13 on GitHub (Dec 4, 2020). Original GitHub issue: https://github.com/ciur/papermerge/issues/242 Originally assigned to: @ciur on GitHub. I converted my SQLite database file to mariadb format using the [rebasedata tool](https://www.rebasedata.com/convert-sqlite-to-mariadb-online). 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
kerem 2026-02-25 21:31:24 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ciur commented on GitHub (Dec 4, 2020):

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

<!-- gh-comment-id:738911185 --> @ciur commented on GitHub (Dec 4, 2020): @amo13, thanks for reporting this issue! Looks like a simple fix.
Author
Owner

@william0353 commented on GitHub (Aug 26, 2021):

now with mysql, still it happens

<!-- gh-comment-id:906461874 --> @william0353 commented on GitHub (Aug 26, 2021): now with mysql, still it happens
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/papermerge#195
No description provided.