{"action":"closed","issue":{"url":"https://api.github.com/repos/KristianOellegaard/django-hvad/issues/267","labels_url":"https://api.github.com/repos/KristianOellegaard/django-hvad/issues/267/labels{/name}","comments_url":"https://api.github.com/repos/KristianOellegaard/django-hvad/issues/267/comments","events_url":"https://api.github.com/repos/KristianOellegaard/django-hvad/issues/267/events","html_url":"https://github.com/KristianOellegaard/django-hvad/issues/267","id":115718694,"number":267,"title":"MySQL error while trying to save TranslatableModel with ManyToMany field related to other TranslatableModel","user":{"login":"sphericalhorse","id":993075,"avatar_url":"https://avatars.githubusercontent.com/u/993075?v=3","gravatar_id":"","url":"https://api.github.com/users/sphericalhorse","html_url":"https://github.com/sphericalhorse","followers_url":"https://api.github.com/users/sphericalhorse/followers","following_url":"https://api.github.com/users/sphericalhorse/following{/other_user}","gists_url":"https://api.github.com/users/sphericalhorse/gists{/gist_id}","starred_url":"https://api.github.com/users/sphericalhorse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphericalhorse/subscriptions","organizations_url":"https://api.github.com/users/sphericalhorse/orgs","repos_url":"https://api.github.com/users/sphericalhorse/repos","events_url":"https://api.github.com/users/sphericalhorse/events{/privacy}","received_events_url":"https://api.github.com/users/sphericalhorse/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-08T09:04:56Z","updated_at":"2015-12-04T18:51:08Z","closed_at":"2015-12-04T18:51:08Z","body":"I have 2 models with custom managers as default:\r\n\r\n    class FallbackManager(hvad_manager.TranslationManager):\r\n        def get_queryset(self):\r\n            return super(FallbackManager, self).language().fallbacks()\r\n    class Contacts(TranslatableModel):\r\n        fallback = FallbackManager()\r\n        translations = TranslatedFields(\r\n            name = models.CharField(),\r\n        )\r\n        ...\r\n    class Event(TranslatableModel):\r\n        fallback = FallbackManager()\r\n        translations = TranslatedFields(\r\n            title = models.CharField(),\r\n        )\r\n        contacts = models.ManyToManyField(Contacts)\r\n        ...\r\n\r\nSo when I try to save Event object using Django admin, I get an error:\r\n\r\n    (1093, \"You can't specify target table 'app_event_contacts' for update in FROM clause\")\r\n\r\nSQL-query that caused error:\r\n\r\n    DELETE FROM `app_event_contacts` WHERE (`app_event_contacts`.`event_id` = 16 AND (`app_event_contacts`.`contacts_id`) IN (SELECT U0.`id` FROM `app_contacts` U0 INNER JOIN `app_event_contacts` U1 ON ( U0.`id` = U1.`contacts_id` ) WHERE U1.`event_id` = 16))\r\n\r\nError appeared when I added the field `contacts` to Event model.\r\nAlso I dont get this error when dont use custom manager for Contacts model."}}