Django Parler 1.9.2 と Django 2.1 を使用しています。関連するモデル (サービスとリソース) を編集するためのインラインを持つビジネス管理者クラスがあります。
class ServiceInline(TranslatableTabularInline):
model = Service
class ResourceInline(TranslatableTabularInline):
model = Resource
@admin.register(Business)
class BusinessAdmin(TranslatableAdmin):
inlines = [ServiceInline, ResourceInline]
管理者でビジネスを編集しようとすると、IntegrityError が表示されます。
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/forms/models.py", line 650, in save_existing
return form.save(commit=commit)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/forms/models.py", line 458, in save
self.instance.save()
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/parler/models.py", line 648, in save
self.save_translations(*args, **kwargs)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/parler/models.py", line 701, in save_translations
self.save_translation(translation, *args, **kwargs)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/parler/models.py", line 728, in save_translation
translation.save(*args, **kwargs)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/base.py", line 717, in save
force_update=force_update, update_fields=update_fields)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/parler/models.py", line 892, in save_base
super(TranslatedFieldsModelMixin, self).save_base(raw=raw, using=using, **kwargs)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/base.py", line 747, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/base.py", line 833, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/base.py", line 872, in _do_insert
using=using, raw=raw)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/query.py", line 1133, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1285, in execute_sql
cursor.execute(sql, params)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/vagrant/.virtualenvs/appy/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "businesses_resource_tran_language_code_master_id_598f5fae_uniq"
DETAIL: Key (language_code, master_id)=(en, 9) already exists.
これを解決する方法はありますか?