dumpdata broken looking for table extras_script #4071

Closed
opened 2025-12-29 18:32:57 +01:00 by adam · 3 comments
Owner

Originally created by @nniehoff on GitHub (Sep 3, 2020).

Environment

  • Python version: 3.8.2
  • NetBox version: 2.9.2

Steps to Reproduce

  1. Install Netbox (or use docker-compose from the netbox-docker project), I followed the docs and got to the point at which I could log in to the UI to test. It was not necessary to create any objects in the DB.
  2. Run:
python manage.py dumpdata --format yaml --traceback

Expected Behavior

Data to be output to stdout in yaml format. NOTE: without the --format yaml argument, json is output to stdout however the error still occurs.

Observed Behavior

When trying to use the dumpdata command to get a current dump of the database I get the following error:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "extras_script" does not exist
LINE 1: ...OR WITH HOLD FOR SELECT "extras_script"."id" FROM "extras_sc...
                                                             ^

For the full traceback see https://pastebin.com/pjk7zFh2

Originally created by @nniehoff on GitHub (Sep 3, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.8.2 * NetBox version: 2.9.2 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Install Netbox (or use docker-compose from the netbox-docker project), I followed the docs and got to the point at which I could log in to the UI to test. It was not necessary to create any objects in the DB. 2. Run: ``` python manage.py dumpdata --format yaml --traceback ``` <!-- What did you expect to happen? --> ### Expected Behavior Data to be output to stdout in yaml format. NOTE: without the `--format yaml` argument, json is output to stdout however the error still occurs. <!-- What happened instead? --> ### Observed Behavior When trying to use the dumpdata command to get a current dump of the database I get the following error: ``` Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "extras_script" does not exist LINE 1: ...OR WITH HOLD FOR SELECT "extras_script"."id" FROM "extras_sc... ^ ``` For the full traceback see https://pastebin.com/pjk7zFh2
adam added the type: bug label 2025-12-29 18:32:57 +01:00
adam closed this issue 2025-12-29 18:32:57 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 4, 2020):

As a workaround, you can exclude these models when running dumpdata:

python manage.py dumpdata --format yaml --traceback -o netbox.yaml --exclude extras.Script --exclude extras.Report
@jeremystretch commented on GitHub (Sep 4, 2020): As a workaround, you can exclude these models when running `dumpdata`: ``` python manage.py dumpdata --format yaml --traceback -o netbox.yaml --exclude extras.Script --exclude extras.Report ```
Author
Owner

@nniehoff commented on GitHub (Sep 4, 2020):

@jeremystretch thanks, confirmed the workaround

@nniehoff commented on GitHub (Sep 4, 2020): @jeremystretch thanks, confirmed the workaround
Author
Owner

@jeremystretch commented on GitHub (Sep 23, 2020):

Short of hijacking Django's dumpdata management command, I don't think we can do much about this. The Report and Script models are designated as "unmanaged" because they don't actually exist in the database but still need to generate content types and permissions. AFAIK changing them to proxy or abstract won't work for this, and Django has decided not to exclude unmanaged models when dumping data.

I'm going to close this out as it seems the workaround mentioned above should suffice.

@jeremystretch commented on GitHub (Sep 23, 2020): Short of hijacking Django's `dumpdata` management command, I don't think we can do much about this. The Report and Script models are designated as "unmanaged" because they don't actually exist in the database but still need to generate content types and permissions. AFAIK changing them to proxy or abstract won't work for this, and Django has [decided not to exclude unmanaged models](https://code.djangoproject.com/ticket/13816) when dumping data. I'm going to close this out as it seems the workaround mentioned above should suffice.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4071