IntegrityError when creating rack group or power panel without site #3333

Closed
opened 2025-12-29 18:27:49 +01:00 by adam · 1 comment
Owner

Originally created by @hSaria on GitHub (Feb 15, 2020).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.6

Steps to Reproduce

  1. Go to rack group create form (/dcim/rack-groups/add/)
  2. Enter name and slug, but leave site empty
  3. Submit

Expected Behavior

The form shouldn't allow me to submit without selecting a site.

Observed Behavior

Exception

<class 'django.db.utils.IntegrityError'>

null value in column "site_id" violates not-null constraint
DETAIL:  Failing row contains (6, Rack Group 1, rg1, null, 2020-02-10, 2020-02-10 13:27:20.503952+00).
Originally created by @hSaria on GitHub (Feb 15, 2020). ### Environment * Python version: 3.6.9 * NetBox version: 2.7.6 ### Steps to Reproduce 1. Go to rack group create form (`/dcim/rack-groups/add/`) 2. Enter name and slug, but leave site empty 3. Submit ### Expected Behavior The form shouldn't allow me to submit without selecting a site. ### Observed Behavior Exception ``` <class 'django.db.utils.IntegrityError'> null value in column "site_id" violates not-null constraint DETAIL: Failing row contains (6, Rack Group 1, rg1, null, 2020-02-10, 2020-02-10 13:27:20.503952+00). ```
adam added the type: bugstatus: accepted labels 2025-12-29 18:27:49 +01:00
adam closed this issue 2025-12-29 18:27:49 +01:00
Author
Owner

@hSaria commented on GitHub (Feb 15, 2020):

Caused by #3912. Just needs:

diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py
index 4c8a0821..e013b0fd 100644
--- a/netbox/dcim/forms.py
+++ b/netbox/dcim/forms.py
@@ -385,7 +385,6 @@ class SiteFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm):
 class RackGroupForm(BootstrapMixin, forms.ModelForm):
     site = DynamicModelChoiceField(
         queryset=Site.objects.all(),
-        required=False,
         widget=APISelect(
             api_url="/api/dcim/sites/"
         )
@hSaria commented on GitHub (Feb 15, 2020): Caused by #3912. Just needs: ```diff diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 4c8a0821..e013b0fd 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -385,7 +385,6 @@ class SiteFilterForm(BootstrapMixin, TenancyFilterForm, CustomFieldFilterForm): class RackGroupForm(BootstrapMixin, forms.ModelForm): site = DynamicModelChoiceField( queryset=Site.objects.all(), - required=False, widget=APISelect( api_url="/api/dcim/sites/" ) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3333