openmeteo / enhydris

A database with a web interface for the storage and management of hydro/meteorological measurements and time series
GNU Affero General Public License v3.0
18 stars 11 forks source link

TypeError: __str__ returned non-string (type NoneType) #357

Closed aptiko closed 4 years ago

aptiko commented 4 years ago

This is in production:

Internal Server Error: /admin/enhydris/station/1468/change/

TypeError at /admin/enhydris/station/1468/change/
__str__ returned non-string (type NoneType)

Request Method: GET
Request URL: https://openmeteo.org/admin/enhydris/station/1468/change/
Django Version: 2.2.2
Python Executable: /opt/enhydris-openmeteo/venv/bin/python3
Python Version: 3.7.3
Python Path: ['/opt/enhydris-openmeteo', '/opt/enhydris-openmeteo', '/opt/enhydris-openmeteo/venv/bin', '/etc/opt/enhydris/openmeteo', '/opt/enhydris-openmeteo/venv/lib/python37.zip', '/opt/enhydris-openmeteo/venv/lib/python3.7', '/opt/enhydris-openmeteo/venv/lib/python3.7/lib-dynload', '/usr/lib/python3.7', '/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Πέμ, 15 Οκτ 2020 09:20:37 +0000
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.humanize',
 'django.contrib.gis',
 'django.contrib.flatpages',
 'django.contrib.postgres',
 'rest_framework',
 'rest_framework.authtoken',
 'rest_auth',
 'bootstrap3',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'rest_auth.registration',
 'rest_captcha',
 'enhydris',
 'enhydris.api',
 'django.contrib.admin',
 'rules.apps.AutodiscoverRulesConfig',
 'parler',
 'nested_admin',
 'enhydris_synoptic',
 'enhydris_autoprocess',
 'enhydris_openhigis']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware']

Traceback:

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  145.                 response = self.process_exception_by_middleware(e, request)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  143.                 response = response.render()

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/response.py" in render
  106.             self.content = self.rendered_content

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/response.py" in rendered_content
  83.         content = template.render(context, self._request)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  150.             return compiled_parent._render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  62.                 result = block.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  62.                 result = block.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  209.                     nodelist.append(node.render_annotated(context))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  188.             return template.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  173.                 return self._render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  513.             return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  513.             return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  513.             return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  209.                     nodelist.append(node.render_annotated(context))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  209.                     nodelist.append(node.render_annotated(context))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/loader_tags.py" in render
  188.             return template.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  173.                 return self._render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  209.                     nodelist.append(node.render_annotated(context))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  209.                     nodelist.append(node.render_annotated(context))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  309.                 return nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/defaulttags.py" in render
  309.                 return nodelist.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render
  993.         return render_value_in_context(output, context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/base.py" in render_value_in_context
  972.             value = str(value)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/utils/html.py" in <lambda>
  388.     klass.__str__ = lambda self: mark_safe(klass_str(self))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/boundfield.py" in __str__
  33.         return self.as_widget()

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/boundfield.py" in as_widget
  93.             renderer=self.form.renderer,

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/widgets.py" in render
  241.         context = self.get_context(name, value, attrs)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/contrib/admin/widgets.py" in get_context
  288.             'rendered_widget': self.widget.render(name, value, attrs),

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/widgets.py" in render
  241.         context = self.get_context(name, value, attrs)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/widgets.py" in get_context
  680.         context = super().get_context(name, value, attrs)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/widgets.py" in get_context
  641.         context['widget']['optgroups'] = self.optgroups(name, context['widget']['value'], attrs)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/widgets.py" in optgroups
  589.         for index, (option_value, option_label) in enumerate(self.choices):

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/models.py" in __iter__
  1138.             yield self.choice(obj)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/models.py" in choice
  1150.         return (self.field.prepare_value(obj), self.field.label_from_instance(obj))

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/forms/models.py" in label_from_instance
  1216.         return str(obj)

Exception Type: TypeError at /admin/enhydris/station/1468/change/
Exception Value: __str__ returned non-string (type NoneType)
aptiko commented 4 years ago

This thing stopped appearing on production without me doing anything. Go figure. Closing the ticket.