agateblue / django-dynamic-preferences

Dynamic global and instance settings for your django project
https://django-dynamic-preferences.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
350 stars 87 forks source link

PerInstancePreferenceAdmin raises MultipleObjectsReturned while saving a per instance preference #285

Closed ShudelEV closed 2 years ago

ShudelEV commented 2 years ago
  File "backend/.venv/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1660, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "backend/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "backend/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "backend/.venv/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1540, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "backend/.venv/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1586, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "backend/.venv/lib/python3.9/site-packages/dynamic_preferences/admin.py", line 80, in save_model
    manager.update_db_pref(pref.section, pref.name, form.cleaned_data["raw_value"])
  File "backend/.venv/lib/python3.9/site-packages/dynamic_preferences/managers.py", line 162, in update_db_pref
    db_pref = self.queryset.get(section=section, name=name)
  File "backend/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 439, in get
    raise self.model.MultipleObjectsReturned(
location.models.location.LocationPreference.MultipleObjectsReturned: get() returned more than one LocationPreference -- it returned 10!