Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hSaria opened this issue Feb 15, 2020 · 1 comment
Closed

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

hSaria opened this issue Feb 15, 2020 · 1 comment
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@hSaria
Copy link
Contributor

hSaria commented 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).
@hSaria
Copy link
Contributor Author

hSaria commented 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/"
         )

@DanSheps DanSheps added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Feb 15, 2020
@jeremystretch jeremystretch changed the title IntegrityError when creating rack group without site IntegrityError when creating rack group or power panel without site Feb 18, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants