django-polymorphic
django-polymorphic copied to clipboard
refresh_from_db() got an unexpected keyword argument 'fields'
Given this code sample
only_fields = (
'foo', 'bar', 'api_request'
)
active_workers = (
worker_api.active_workers()
.exclude(api_request=None)
.only(*only_fields)
)
for worker in active_workers:
print('foobar')
When evaluating active_workers in the iterable, the following is thrown:
refresh_from_db() got an unexpected keyword argument 'fields'
worker_api.active_workers() return a Queryset of Worker objects which are django-polymorphic classes from a Provider class.
We've been able to get around this buy using prefetch_related('api_request') instead of explicit fields using .only. This approach returns too much data, but is still performant.
This looks like a bug when prefetching specific fields, which from the docs seems to be supported.
Any help welcome! Thanks
Django 1.11.29 Django Polymorphic 2.1.2 Python 2.7