Skip to content
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

Power outlet creation fails - PowerOutlet has no device. #3130

Closed
depereo opened this issue May 1, 2019 · 0 comments
Closed

Power outlet creation fails - PowerOutlet has no device. #3130

depereo opened this issue May 1, 2019 · 0 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@depereo
Copy link

depereo commented May 1, 2019

Environment

  • Python version: 3.6.6
  • NetBox version: develop-2.6

Steps to Reproduce

  1. On an existing device, create a new power outlet component via the 'add component' form (dcim/devices/device_id/power-outlets/add/)
  2. click submit

Expected Behavior

Power outlet created

Observed Behavior

Traceback -

<class 'dcim.models.PowerOutlet.device.RelatedObjectDoesNotExist'>

PowerOutlet has no device.

Debug details:

Environment:


Request Method: POST
Request URL: https://netbox.domain.local/dcim/devices/3105/power-outlets/add/

Django Version: 2.2
Python Version: 3.6.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cacheops',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'mptt',
 'rest_framework',
 'taggit',
 'taggit_serializer',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'drf_yasg']
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.ExceptionHandlingMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware',
 'extras.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware')



Traceback:

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py" in view
  71.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/mixins.py" in dispatch
  85.         return super().dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  97.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/utilities/views.py" in post
  744.                 component_form = self.model_form(data)

File "/opt/netbox/netbox/dcim/forms.py" in __init__
  2010.             device=self.instance.device

File "/usr/local/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in __get__
  189.                 "%s has no %s." % (self.field.model.__name__, self.field.name)

Exception Type: RelatedObjectDoesNotExist at /dcim/devices/3105/power-outlets/add/
Exception Value: PowerOutlet has no device.

If I remove the 'limit power_port choices to the local device' part of dcim/forms.py, this works perfectly well.

If I comment out the below from PowerOutletForm this works as expected - power_port isn't currently part of PowerOutletCreateForm so this doesn't appear to have a lot of impact currently.

Relevant code introduced in 3d5f85c:

        # Limit power_port choices to the local device
        self.fields['power_port'].queryset = PowerPort.objects.filter(
            device=self.instance.device
        )

@jeremystretch jeremystretch added beta status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels May 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 16, 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

No branches or pull requests

2 participants