aptiko / openhi

Project management for OpenHI—no code, mainly issues
0 stars 0 forks source link

Internal server error: duplicate key value violates unique constraint "only_one_raw_or_processed_timeseries_per_group" #84

Closed aptiko closed 3 years ago

aptiko commented 3 years ago
Internal Server Error: /admin/enhydris/station/1464/change/

IntegrityError at /admin/enhydris/station/1464/change/
duplicate key value violates unique constraint "only_one_raw_or_processed_timeseries_per_group"
DETAIL:  Key (timeseries_group_id)=(509) already exists.

Request Method: POST
Request URL: https://system.openhi.net/admin/enhydris/station/1464/change/
Django Version: 2.2.2
Python Executable: /opt/enhydris-openhi/venv/bin/python3
Python Version: 3.7.3
Python Path: ['/opt/enhydris-openhi', '/opt/enhydris-openhi', '/opt/enhydris-openhi/venv/bin', '/etc/opt/enhydris/openhi', '/opt/enhydris-openhi/venv/lib/python37.zip', '/opt/enhydris-openhi/venv/lib/python3.7', '/opt/enhydris-openhi/venv/lib/python3.7/lib-dynload', '/usr/lib/python3.7', '/opt/enhydris-openhi/venv/lib/python3.7/site-packages', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Tue, 1 Dec 2020 21:19:06 +0200
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-openhi/venv/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
  84.                 return self.cursor.execute(sql, params)

The above exception (duplicate key value violates unique constraint "only_one_raw_or_processed_timeseries_per_group"
DETAIL:  Key (timeseries_group_id)=(509) already exists.
) was the direct cause of the following exception:

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

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

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/options.py" in wrapper
  606.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/sites.py" in inner
  223.             return view(request, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/options.py" in change_view
  1637.         return self.changeform_view(request, object_id, form_url, extra_context)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper
  45.         return bound_method(*args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/options.py" in changeform_view
  1522.             return self._changeform_view(request, object_id, form_url, extra_context)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/options.py" in _changeform_view
  1562.                 self.save_related(request, form, formsets, not add)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/options.py" in save_related
  1116.             self.save_formset(request, form, formset, change=change)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/contrib/admin/options.py" in save_formset
  1104.         formset.save()

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/nested_admin/formsets.py" in save
  149.             instance = self.get_saved_instance_for_form(form, commit, form_instances)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/nested_admin/formsets.py" in get_saved_instance_for_form
  237.             instances = self.save_new_objects([form], commit)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/nested_admin/formsets.py" in save_new_objects
  387.             new_objects.append(self.save_new(form, commit=commit))

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/forms/models.py" in save_new
  947.         return super().save_new(form, commit=commit)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/forms/models.py" in save_new
  646.         return form.save(commit=commit)

File "/opt/enhydris-openhi/enhydris/admin/station.py" in save
  172.         result = super().save(*args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/forms/models.py" in save
  458.             self.instance.save()

File "/opt/enhydris-openhi/enhydris/models.py" in save
  687.         super(Timeseries, self).save(force_insert, force_update, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/base.py" in save
  741.                        force_update=force_update, update_fields=update_fields)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/base.py" in save_base
  779.                 force_update, using, update_fields,

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/base.py" in _save_table
  870.             result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/base.py" in _do_insert
  908.                                using=using, raw=raw)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method
  82.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/query.py" in _insert
  1186.         return query.get_compiler(using=using).execute_sql(return_id)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1335.                 cursor.execute(sql, params)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/backends/utils.py" in execute
  67.         return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
  76.         return executor(sql, params, many, context)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
  84.                 return self.cursor.execute(sql, params)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/utils.py" in __exit__
  89.                 raise dj_exc_value.with_traceback(traceback) from exc_value

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute
  84.                 return self.cursor.execute(sql, params)

Exception Type: IntegrityError at /admin/enhydris/station/1464/change/
Exception Value: duplicate key value violates unique constraint "only_one_raw_or_processed_timeseries_per_group"
DETAIL:  Key (timeseries_group_id)=(509) already exists.
aptiko commented 3 years ago

Wrong repo.