models.py
class BaseMedia(AbstractObject):
staff = models.ManyToManyField('main.Profession', blank=True)
# etc
class Profession(Id):
profession = models.CharField(max_length=15)
creator = models.ForeignKey('main.Creator', on_delete=models.CASCADE)
character = models.ForeignKey('main.Character', on_delete=models.CASCADE, null=True, blank=True)
forms.py
for profession, staff in staff.items():
for person in staff:
professions.append(Profession.objects.update_or_create(
profession=profession,
creator_id=person.get('creator_id'),
character_id=person.get('character_id')
)[0])
instance.staff.set(professions)
instance.staff.set(professions)
из forms.py повышение:
django.db.utils.IntegrityError: update or delete on table "main_profession" violates
foreign key constraint "main_basemedia_staff_profession_id_075458d2_fk_main_prof" on
table "main_basemedia_staff"
DETAIL: Key (id)=(dd032d79-d458-4ead-b05b-da3b419b58a0) is still referenced from table
"main_basemedia_staff".
Я абсолютно не знаю, в чем суть этой проблемы.