TypeError: UniqueConstraint Error in v3.4.0 #8167

Closed
opened 2025-12-29 20:33:22 +01:00 by adam · 5 comments
Owner

Originally created by @WilliamMarti on GitHub (Jun 7, 2023).

NetBox version

v3.4.0

Python version

3.10

Steps to Reproduce

  1. My Netbox instance has been running on v3.3.7 for some time now just fine.
  2. Attempted to upgrade to the latest v3.5.3 but have been running into the following error
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.10/dist-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/commands/runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python3.10/dist-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 375, in execute
    autoreload.check_errors(django.setup)()
  File "/usr/local/lib/python3.10/dist-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.10/dist-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/usr/local/lib/python3.10/dist-packages/django/apps/config.py", line 301, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/netbox/netbox/circuits/models/__init__.py", line 1, in <module>
    from .circuits import *
  File "/opt/netbox/netbox/circuits/models/circuits.py", line 9, in <module>
    from dcim.models import CabledObjectModel
  File "/opt/netbox/netbox/dcim/models/__init__.py", line 4, in <module>
    from .devices import *
  File "/opt/netbox/netbox/dcim/models/devices.py", line 444, in <module>
    class Device(PrimaryModel, ConfigContextModel):
  File "/opt/netbox/netbox/dcim/models/devices.py", line 609, in Device
    class Meta:
  File "/opt/netbox/netbox/dcim/models/devices.py", line 612, in Meta
    models.UniqueConstraint(
TypeError: UniqueConstraint.__init__() takes 1 positional argument but 4 positional arguments (and 1 keyword-only argument) were given

I've tried a few different upgrade paths but nothing seems to be working, ex:

v3.3.7 -> v3.4.0
v3.3.7 -> v3.3.10 -> v3.4.0

Everything works up until I go to v3.4 and I start seeing the above error.

I had 1 existing ConfigContext that I deleted that I thought could have been a problem which I deleted, same issue afterwards. Not sure how exactly to read the message, do I have duplicate Device name in my DB ?

Expected Behavior

Expecting to be able run my Netbox instance from v3.4 normally

Observed Behavior

A TypeError Exception was raised

Originally created by @WilliamMarti on GitHub (Jun 7, 2023). ### NetBox version v3.4.0 ### Python version 3.10 ### Steps to Reproduce 1. My Netbox instance has been running on v3.3.7 for some time now just fine. 2. Attempted to upgrade to the latest v3.5.3 but have been running into the following error ``` Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.10/dist-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/django/core/management/commands/runserver.py", line 110, in inner_run autoreload.raise_last_exception() File "/usr/local/lib/python3.10/dist-packages/django/utils/autoreload.py", line 87, in raise_last_exception raise _exception[1] File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 375, in execute autoreload.check_errors(django.setup)() File "/usr/local/lib/python3.10/dist-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.10/dist-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/usr/local/lib/python3.10/dist-packages/django/apps/config.py", line 301, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/opt/netbox/netbox/circuits/models/__init__.py", line 1, in <module> from .circuits import * File "/opt/netbox/netbox/circuits/models/circuits.py", line 9, in <module> from dcim.models import CabledObjectModel File "/opt/netbox/netbox/dcim/models/__init__.py", line 4, in <module> from .devices import * File "/opt/netbox/netbox/dcim/models/devices.py", line 444, in <module> class Device(PrimaryModel, ConfigContextModel): File "/opt/netbox/netbox/dcim/models/devices.py", line 609, in Device class Meta: File "/opt/netbox/netbox/dcim/models/devices.py", line 612, in Meta models.UniqueConstraint( TypeError: UniqueConstraint.__init__() takes 1 positional argument but 4 positional arguments (and 1 keyword-only argument) were given ``` I've tried a few different upgrade paths but nothing seems to be working, ex: v3.3.7 -> v3.4.0 v3.3.7 -> v3.3.10 -> v3.4.0 Everything works up until I go to v3.4 and I start seeing the above error. I had 1 existing ConfigContext that I deleted that I thought could have been a problem which I deleted, same issue afterwards. Not sure how exactly to read the message, do I have duplicate Device name in my DB ? ### Expected Behavior Expecting to be able run my Netbox instance from v3.4 normally ### Observed Behavior A TypeError Exception was raised
adam closed this issue 2025-12-29 20:33:23 +01:00
Author
Owner

@DanSheps commented on GitHub (Jun 7, 2023):

What version off Django are you using?

@DanSheps commented on GitHub (Jun 7, 2023): What version off Django are you using?
Author
Owner

@WilliamMarti commented on GitHub (Jun 7, 2023):

Running

 python3 -m django --version

gives me

3.2.11
@WilliamMarti commented on GitHub (Jun 7, 2023): Running ``` python3 -m django --version ``` gives me ``` 3.2.11 ```
Author
Owner

@WilliamMarti commented on GitHub (Jun 7, 2023):

Guessing this was due to me using an older version of Django, manually ran a pip3 install -r requirements.txt and things are now working for me. Thanks for the hint!

@WilliamMarti commented on GitHub (Jun 7, 2023): Guessing this was due to me using an older version of Django, manually ran a `pip3 install -r requirements.txt` and things are now working for me. Thanks for the hint!
Author
Owner

@DanSheps commented on GitHub (Jun 7, 2023):

You should idealy be running this in a venv and rebuilding the entire venv with ./upgrade.sh when you upgrade instead.

@DanSheps commented on GitHub (Jun 7, 2023): You should idealy be running this in a venv and rebuilding the entire venv with ./upgrade.sh when you upgrade instead.
Author
Owner

@WilliamMarti commented on GitHub (Jun 7, 2023):

Yeah agreed, this is a fairly "old" deployment we've been upgrading since prolly around v1.4. Prolly need to re-deploy with some of the more up-to-date methods/configurations. But anyway thanks again!

@WilliamMarti commented on GitHub (Jun 7, 2023): Yeah agreed, this is a fairly "old" deployment we've been upgrading since prolly around v1.4. Prolly need to re-deploy with some of the more up-to-date methods/configurations. But anyway thanks again!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8167