Closed srtonz closed 7 years ago
Can you bring in an example? What kind of backend you use? How backend can change querysets? And what exception with stacktrace you get?
File "/vagrant/env/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/vagrant/env/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/vagrant/env/lib/python3.5/site-packages/django/apps/registry.py", line 116, in populate
app_config.ready()
File "/vagrant/env/lib/python3.5/site-packages/cacheops/__init__.py", line 18, in ready
install_cacheops()
File "/vagrant/env/lib/python3.5/site-packages/funcy/flow.py", line 172, in wrapper
return func(*args, **kwargs)
File "/vagrant/env/lib/python3.5/site-packages/cacheops/query.py", line 569, in install_cacheops
model._default_manager._install_cacheops(model)
AttributeError: 'DjangoCassandraQuerySet' object has no attribute '_install_cacheops'
There are multiple possibilities this can fail, I think it'd be nice if cacheops could handle it gracefully. In the case of django-cassandra-engine
, there's no difference between the manager and the queryset class. Its QuerySet doesn't inherit from Django's Manager
or QuerySet
and is therefore not monkeypatched.
Should be fixed in 037e23a.
I found that
django-cacheops
refuses to work with certain DB backends that aren't using Django'sQuerySet
orManager
classes.The problem is that
cacheops
attempts setup for all models registered with Django (here: https://github.com/Suor/django-cacheops/blob/master/cacheops/query.py#L548) . If it can't install (because_install_cacheops
isn't set), the whole processes crashes.I wonder if you could wrap that part in a
try..except
like so: