{"action":"created","issue":{"url":"https://api.github.com/repos/Suor/django-cacheops/issues/131","labels_url":"https://api.github.com/repos/Suor/django-cacheops/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/Suor/django-cacheops/issues/131/comments","events_url":"https://api.github.com/repos/Suor/django-cacheops/issues/131/events","html_url":"https://github.com/Suor/django-cacheops/issues/131","id":53965370,"number":131,"title":"Yet another threading issue with m2m (v2.2.1)","user":{"login":"pySilver","id":1113925,"avatar_url":"https://avatars.githubusercontent.com/u/1113925?v=3","gravatar_id":"","url":"https://api.github.com/users/pySilver","html_url":"https://github.com/pySilver","followers_url":"https://api.github.com/users/pySilver/followers","following_url":"https://api.github.com/users/pySilver/following{/other_user}","gists_url":"https://api.github.com/users/pySilver/gists{/gist_id}","starred_url":"https://api.github.com/users/pySilver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pySilver/subscriptions","organizations_url":"https://api.github.com/users/pySilver/orgs","repos_url":"https://api.github.com/users/pySilver/repos","events_url":"https://api.github.com/users/pySilver/events{/privacy}","received_events_url":"https://api.github.com/users/pySilver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-01-10T17:42:24Z","updated_at":"2015-01-13T17:42:20Z","closed_at":null,"body":"Hello,\r\n\r\nI'm experiencing a serious problems with m2m fields when cacheops is enabled. I belive the problem is somewhere in threading support because it does not appear with development server (and as a result tests passes but features gets broken on production).\r\n\r\nSee the code:\r\n\r\nmodel (simplified):\r\n```python\r\nclass WebsiteCategory(models.Model):\r\n\r\n    code = models.CharField(\r\n        verbose_name=_(u'category'),\r\n        max_length=80,\r\n        choices=WEBSITE_CATEGORIES,\r\n        unique=True,\r\n    )\r\n\r\n    class Meta:\r\n        ordering = ['code']\r\n        verbose_name = _(u\"category\")\r\n        verbose_name_plural = _(u\"categories\")\r\n\r\n    def __unicode__(self):\r\n        return self.get_code_display()\r\n\r\nclass Website(VersionMixin):\r\n    url = models.URLField(\r\n        verbose_name=_(u\"URL\"),\r\n        max_length=255)\r\n\r\n    description = models.CharField(\r\n        blank=True,\r\n        default=\"\",\r\n        max_length=500)\r\n\r\n    categories = models.ManyToManyField(\r\n        'categories.WebsiteCategory',\r\n        related_name='websites')\r\n```\r\n\r\nsettings.py:\r\n```python\r\n########## CACHEOPS CONFIGURATION\r\nCACHEOPS_DEFAULTS = {\r\n    'timeout': 60 * 60 * 24  # 24 hours\r\n}\r\n\r\nCACHEOPS = {\r\n    # ... skipped unrelated apps\r\n\r\n    # Categories\r\n    'categories.websitecategory': {'ops': 'all'},\r\n\r\n    # Websites\r\n    'websites.website': {'ops': 'all'},\r\n\r\n    ### THIRD PARTY APPS ###\r\n    'auth.*': {'ops': 'all'},\r\n    'sites.*': {'ops': 'all'},\r\n    'authtoken.*': {'ops': 'all'},\r\n    'notification.*': {'ops': 'all'},\r\n    'oauth2.*': {'ops': 'all'},\r\n}\r\n########## END CACHEOPS CONFIGURATION\r\n```\r\n\r\nHere is how problem appears to the end user: User fills the website creation form by providing url, description and selecting few categories and hits \"SAVE\" button. `Website` is now in cache and in db. \r\nUser tries to update created object and there is a failure – he can update everything but not a `categories` m2m field. \r\n\r\nSo I've tried to do a couple of experiments.\r\n\r\nI run `./manage.py shell_plus` to get into console, loaded a `Website` object there and changed categories. Refreshed page on a website – categories were updated. *NEXT PART IS STRANGE*. Then I've immediately tried to update categories using website – `categories` field were updated on db lvl, but reading still returns *old* m2m set on a web interface (console returns fresh results). *Subsequent* attempts to update object using web interface *does not* hit db any more. At this point I've tried to invalite_obj, invalite_model from console, but web interface still output *old categories set*. I belive this has nothing to do with a browser cache, nor with UI.\r\n\r\nI'm mostly positive it has something to do with threading support and has nothing do to with UI (In my case it's DRF API, so I've tried to update object using same serializer inside a console and it works fine, same as if I update an object directly without serializer layer).\r\n\r\nOnce I set `CACHEOPS_FAKE` to `True` all problems with m2m gone away. So it's for sure something related to cacheops.\r\n\r\n@Suor can you please give any directions how may I find out the source of this problem? Thank you very much for your work!"},"comment":{"url":"https://api.github.com/repos/Suor/django-cacheops/issues/comments/69785721","html_url":"https://github.com/Suor/django-cacheops/issues/131#issuecomment-69785721","issue_url":"https://api.github.com/repos/Suor/django-cacheops/issues/131","id":69785721,"user":{"login":"Suor","id":284103,"avatar_url":"https://avatars.githubusercontent.com/u/284103?v=3","gravatar_id":"","url":"https://api.github.com/users/Suor","html_url":"https://github.com/Suor","followers_url":"https://api.github.com/users/Suor/followers","following_url":"https://api.github.com/users/Suor/following{/other_user}","gists_url":"https://api.github.com/users/Suor/gists{/gist_id}","starred_url":"https://api.github.com/users/Suor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suor/subscriptions","organizations_url":"https://api.github.com/users/Suor/orgs","repos_url":"https://api.github.com/users/Suor/repos","events_url":"https://api.github.com/users/Suor/events{/privacy}","received_events_url":"https://api.github.com/users/Suor/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T17:42:20Z","updated_at":"2015-01-13T17:42:20Z","body":"And check your `sys.path` with:\r\n```python\r\nimport sys\r\nprint sys.path\r\n```"}}