django-pandas icon indicating copy to clipboard operation
django-pandas copied to clipboard

Possible to have read_frame work with RawQuerySet ?

Open stellasia opened this issue 6 years ago • 3 comments

When trying to use read_frame with a RawQuerySet :

from django_pandas.io import read_frame
from apps.immodata.models import Observation

obj = MyModel.objects.raw("Select * from myapp_mymodel") # dummy RawQuerySet

read_frame(obj)

getting this error :

venv/lib/python3.5/site-packages/django_pandas/io.py in read_frame(qs, fieldnames, index_col, coerce_float, verbose)
     74             fieldnames = tuple(fieldnames) + (index_col,)
     75         fields = to_fields(qs, fieldnames)
---> 76     elif is_values_queryset(qs):
     77         if django.VERSION < (1, 9):
     78             if django.VERSION < (1, 8):

venv/lib/python3.5/site-packages/django_pandas/io.py in is_values_queryset(qs)
     30         return isinstance(qs, django.db.models.query.ValuesQuerySet)
     31     else:
---> 32         return qs._iterable_class == django.db.models.query.ValuesIterable
     33 
     34 

AttributeError: 'RawQuerySet' object has no attribute '_iterable_class'

Is there a workaround?

stellasia avatar Apr 04 '18 12:04 stellasia

Can I lnow why thos was closed without any more information ?

stellasia avatar Feb 04 '19 06:02 stellasia

Sorry @stellasia we were closing a number of PRs as part of the decision not to support the versions of Django prior to 1.11 I guess this got thrown in the mix? I will revisit this one. Do you have a PR for this?

chrisdev avatar Feb 04 '19 13:02 chrisdev

Hi @chrisdev

No I do not have a PR because actually I would not know from where to start to fix the issue. If you have any advice, I can investigate more.

And I will check the error is still there for django >= 1..11 (no guarantee I was using this version for my first post)

Thanks :)

stellasia avatar Feb 04 '19 14:02 stellasia