[ ] Feature request
[x] Bug report
[ ] Documentation
Assuming there is a basic setup of manufacturer, sites, a device and so on.
------), saveSadly I can't reproduce this in the docker-compose setup.
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/auth/mixins.py", line 92, in dispatch
return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "/opt/netbox/netbox/utilities/views.py", line 196, in post
obj = form.save()
File "/opt/netbox/netbox/extras/forms.py", line 123, in save
self._save_custom_fields()
File "/opt/netbox/netbox/extras/forms.py", line 116, in _save_custom_fields
cfv.save()
File "/opt/netbox/netbox/extras/models.py", line 169, in save
if self.pk and self.value is None:
File "/opt/netbox/netbox/extras/models.py", line 161, in value
return self.field.deserialize_value(self.serialized_value)
File "/opt/netbox/netbox/extras/models.py", line 140, in deserialize_value
return self.choices.get(pk=int(serialized_value))
ValueError: invalid literal for int() with base 10: ''
but funnily enough there is a check for exactly this case a few lines about the crash site:
if serialized_value is '':
return None
I just tested this on python 3.4 and did not get any errors. Given that it isn't reproducible in python 3.4 or on the docker setup, are you sure it isn't a problem with your setup somehow?
This bug affects only Python 2.
@luto I can confirm that your PR #1981 fixes the issue. I _believe_ the evaluation is performed using is because at one point the value was being compared against None rather than an empty string. Good catch!
This bug affects only Python 2
I only later noticed that the docker setup is running the more sane py3, which is why I couldn't reproduce it :man_facepalming: Thanks for the quick merge! :)