Skip to content

Getting An unknown error occurred while rendering the preview. When rendering PDF preview #11475

@c0fe

Description

@c0fe

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

I am getting the following error when attempting to render a PDF preview in the template editing section of Inventree:

https://i.imgur.com/XFPETqY.png

Steps to Reproduce

  1. Create Item
  2. Create Vendor
  3. Create Purchase Order
  4. Go to Admin Center
  5. Go to Report Template
  6. Select InvenTree Purchase Order
  7. Press Save & Reload Preview

Expected behaviour

Renders PDF preview

Deployment Method

Docker

Version Information

InvenTree-Version: 1.2.3
Django Version: 5.2.11
Commit Hash: 12da3b0
Commit Date: 2026-02-22
Commit Branch: null
Database: django.db.backends.postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.12.57+deb13-amd64-x86_64-with-glibc2.41
Installer: DOC
Active plugins: [{"name":"InvenTreeBarcode","slug":"inventreebarcode","version":"2.1.0"},{"name":"BOM Exporter","slug":"bom-exporter","version":"1.1.0"},{"name":"InvenTree Exporter","slug":"inventree-exporter","version":"1.0.0"},{"name":"Part Parameter Exporter","slug":"parameter-exporter","version":"1.0.0"},{"name":"InvenTreeEmailNotifications","slug":"inventree-email-notification","version":"1.0.0"},{"name":"InvenTreeUINotifications","slug":"inventree-ui-notification","version":"1.0.0"},{"name":"InvenTreeCurrencyExchange","slug":"inventreecurrencyexchange","version":"1.0.0"},{"name":"InvenTreeMachines","slug":"inventree-machines","version":"1.0.0"},{"name":"InvenTreeLabel","slug":"inventreelabel","version":"1.1.0"},{"name":"InvenTreeLabelMachine","slug":"inventreelabelmachine","version":"1.0.0"}]

Try to reproduce on the demo site

I did not try to reproduce

Is the bug reproducible on the demo site?

Not reproducible

Relevant log output

Error in the worker container:

    raise ex.with_traceback(None)
psycopg.errors.UndefinedTable: relation "users_userprofile" does not exist
LINE 1: INSERT INTO "users_userprofile" ("metadata", "user_id", "lan...
                    ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/inventree/src/backend/InvenTree/manage.py", line 25, in <module>
    main()
  File "/home/inventree/src/backend/InvenTree/manage.py", line 21, in main
    execute_from_command_line(sys.argv)
  File "/root/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/root/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
  File "/root/.local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/root/.local/lib/python3.11/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/home/inventree/src/backend/InvenTree/InvenTree/apps.py", line 77, in ready
    self.add_user_on_startup()
  File "/home/inventree/src/backend/InvenTree/InvenTree/ready.py", line 199, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/inventree/src/backend/InvenTree/InvenTree/apps.py", line 275, in add_user_on_startup
    self._create_admin_user(add_user, add_email, add_password)
  File "/home/inventree/src/backend/InvenTree/InvenTree/apps.py", line 287, in _create_admin_user
    new_user = user.objects.create_superuser(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/contrib/auth/models.py", line 195, in create_superuser
    return self._create_user(username, email, password, **extra_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/contrib/auth/models.py", line 163, in _create_user
    user.save(using=self._db)
  File "/root/.local/lib/python3.11/site-packages/django/contrib/auth/base_user.py", line 65, in save
    super().save(*args, **kwargs)
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 1023, in save_base
    post_save.send(
  File "/root/.local/lib/python3.11/site-packages/django/dispatch/dispatcher.py", line 189, in send
    response = receiver(signal=self, sender=sender, **named)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/inventree/src/backend/InvenTree/users/models.py", line 604, in create_or_update_user_profile
    UserProfile.objects.create(user=instance)
  File "/root/.local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 665, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/inventree/src/backend/InvenTree/users/models.py", line 596, in save
    super().save(*args, **kwargs)
  File "/home/inventree/src/backend/InvenTree/InvenTree/models.py", line 179, in save
    super().save(force_insert=force_insert, force_update=force_update, **kwargs)
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 902, in save
    self.save_base(
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 1008, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 1169, in _save_table
    results = self._do_insert(
              ^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/base.py", line 1210, in _do_insert
    return manager._insert(
           ^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/query.py", line 1873, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1882, in execute_sql
    cursor.execute(sql, params)
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/root/.local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/.local/lib/python3.11/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.11/site-packages/psycopg/cursor.py", line 117, in execute
    raise ex.with_traceback(None)
django.db.utils.ProgrammingError: relation "users_userprofile" does not exist
LINE 1: INSERT INTO "users_userprofile" ("metadata", "user_id", "lan...
                    ^
ERROR: InvenTree command failed: 'python3 manage.py qcluster'
- Refer to the error messages in the log above for more information
Loading config file : /home/inventree/data/config.yaml
Waiting for database connection...
INVE-W3: Could not detect git information.
Waiting for database...
Database connection successful!
INVE-W3: Could not detect git information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentifies a bug which needs to be addressedquestionThis is a questiontriage:not-checkedItem was not checked by the core team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions