denshoproject / namesdb-editor

Other
0 stars 0 forks source link

`'NoneType' object has no attribute 'id'` when editing Person-Location record #42

Closed GeoffFroh closed 1 year ago

GeoffFroh commented 1 year ago

When attempting to edit an existing Person-Location record, names editor throws an 'NoneType' object has no attribute 'id' exception. (May be related to #41?)

URL: http://namesdbeditor.local/admin/names/personlocation/209271/change/

Traceback:

Environment:

Request Method: POST
Request URL: http://namesdbeditor.local/admin/names/personlocation/209271/change/

Django Version: 4.1.11
Python Version: 3.9.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'bootstrap_pagination',
 'drf_yasg',
 'rest_framework',
 'editor',
 'names',
 'namesdb_public']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 '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']

Traceback (most recent call last):
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/contrib/admin/options.py", line 686, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/utils/decorators.py", line 134, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 242, in inner
    return view(request, *args, **kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1894, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/utils/decorators.py", line 134, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1751, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1797, in _changeform_view
    form_validated = form.is_valid()
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/forms.py", line 205, in is_valid
    return self.is_bound and not self.errors
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/forms.py", line 200, in errors
    self.full_clean()
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/forms.py", line 437, in full_clean
    self._clean_fields()
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/forms.py", line 449, in _clean_fields
    value = field.clean(value)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/fields.py", line 199, in clean
    self.validate(value)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/models.py", line 1554, in validate
    return Field.validate(self, value)
  File "/opt/namesdb-editor/venv/names/lib/python3.9/site-packages/django/forms/fields.py", line 176, in validate
    if value in self.empty_values and self.required:
  File "/opt/namesdb-editor/src/names/models.py", line 200, in __eq__
    return self.id == other.id

Exception Type: AttributeError at /admin/names/personlocation/209271/change/
Exception Value: 'NoneType' object has no attribute 'id'