Suor/django-cacheops — Issue #7: ManyToMany models problem in Django Admin users management
Author: Aeron
Created: 2011-11-22 11:45:38+00:00
State: open

If I’ve changed something about Django user in Admin, it’ll raise exception about m2m instance have no “_cacheprofile” attribute.
CacheOps config contain 3 rows from documentation expamles that related to user model:

```python
CACHEOPS = {
'auth.user': ('get', 60*15),
'auth.*': ('all', 60*60),
# 'my_apps.*': ('all', 60*30),
'*.*': ('count', 60*15),
}
```

```
Traceback (most recent call last):

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py", line 307, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py", line 197, in inner
return view(request, *args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py", line 28, in _wrapper
return bound_func(*args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py", line 24, in bound_func
return func(self, *args2, **kwargs2)

File "/usr/local/lib/python2.6/dist-packages/django/db/transaction.py", line 217, in inner
res = func(*args, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py", line 983, in change_view
form.save_m2m()

File "/usr/local/lib/python2.6/dist-packages/django/forms/models.py", line 82, in save_m2m
f.save_form_data(instance, cleaned_data[f.name])

File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/related.py", line 1149, in save_form_data
setattr(instance, self.attname, data)

File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/related.py", line 745, in __set__
manager.clear()

File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/related.py", line 519, in clear
self._clear_items(self.source_field_name)

File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/related.py", line 641, in _clear_items
source_field_name: self._pk_val

File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 444, in delete
collector.collect(del_query)

File "/usr/local/lib/python2.6/dist-packages/django/db/models/deletion.py", line 146, in collect
reverse_dependency=reverse_dependency)

File "/usr/local/lib/python2.6/dist-packages/django/db/models/deletion.py", line 91, in add
if not objs:

File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 113, in __nonzero__
iter(self).next()

File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()

File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())

File "/usr/local/lib/python2.6/dist-packages/cacheops/query.py", line 341, in iterator
self._cache_results(cache_key, results)

File "/usr/local/lib/python2.6/dist-packages/cacheops/query.py", line 241, in _cache_results
cache_thing(self.model, cache_key, results, cond_dnf, timeout=self._cachetimeout)

File "/usr/local/lib/python2.6/dist-packages/cacheops/query.py", line 54, in cache_thing
txn.expire(conj_key, model._cacheprofile['timeout'] + 10)

AttributeError: type object 'User_groups' has no attribute '_cacheprofile'
```