{"action":"closed","issue":{"url":"https://api.github.com/repos/django-debug-toolbar/django-debug-toolbar/issues/670","labels_url":"https://api.github.com/repos/django-debug-toolbar/django-debug-toolbar/issues/670/labels{/name}","comments_url":"https://api.github.com/repos/django-debug-toolbar/django-debug-toolbar/issues/670/comments","events_url":"https://api.github.com/repos/django-debug-toolbar/django-debug-toolbar/issues/670/events","html_url":"https://github.com/django-debug-toolbar/django-debug-toolbar/issues/670","id":50304265,"number":670,"title":"cache.clear() not available inside a view function","user":{"login":"chrkr","id":3919808,"avatar_url":"https://avatars.githubusercontent.com/u/3919808?v=3","gravatar_id":"","url":"https://api.github.com/users/chrkr","html_url":"https://github.com/chrkr","followers_url":"https://api.github.com/users/chrkr/followers","following_url":"https://api.github.com/users/chrkr/following{/other_user}","gists_url":"https://api.github.com/users/chrkr/gists{/gist_id}","starred_url":"https://api.github.com/users/chrkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrkr/subscriptions","organizations_url":"https://api.github.com/users/chrkr/orgs","repos_url":"https://api.github.com/users/chrkr/repos","events_url":"https://api.github.com/users/chrkr/events{/privacy}","received_events_url":"https://api.github.com/users/chrkr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/django-debug-toolbar/django-debug-toolbar/labels/Bug","name":"Bug","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-11-27T15:48:20Z","updated_at":"2015-05-10T21:36:27Z","closed_at":"2015-05-10T21:36:27Z","body":"cache.clear() raises NotImplementedError during request/view processing between debug toolbar middleware request processing and debug toolbar middleware response processing.\r\n\r\nThis is a copy of my message in closed issue #570:\r\n\r\nIt took me all of 10 minutes to find out why this was happening in my project, inside a view function:\r\n- the cache panel replaces the default cache (and the get_cache) function during the request middleware processing with CacheStatTracker/a function returning CacheStatTracker\r\n- processing continues until the actual view function is called\r\n- cache.clear() is called inside the view function, on CacheStatTracker\r\n- CacheStatTracker has no clear() method, but has inherited the clear() method from BaseCache\r\n- clear() is called on BaseCache\r\n- BaseCache raises NotImplementedError\r\n\r\nYou won't find this occurring outside a view function, because on the way back out, the processing passes through the debug toolbar middleware again, this time calling disable_instrumentation on the cache panel, which replaces the cache/get_cache with the original values again."}}