Skip to content

Possible to have read_frame work with RawQuerySet ? #101

@stellasia

Description

@stellasia

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions