TypeError: index_queryset() got an unexpected keyword argument 'using'

1.2k Views Asked by At
Django==3.2.5
django-haystack==3.0
pysolr==3.9.0

Solr = 8.9.0

I am following the tutorial as in https://django-haystack.readthedocs.io/en/master/tutorial.html to create an Django application with Solr.

While executing ./manage.py rebuild_index, I am getting an error like:

 **File "/..../tele_env/lib/python3.8/site-packages/haystack/indexes.py", 
line  202, in build_queryset
index_qs = self.index_queryset(using=using)
TypeError: index_queryset() got an unexpected keyword argument 'using'** 

I am stuck up since 3 days solving this error. Tried to downgrade each of the packages (Django, pysolr, haystack with solr 6.6, but didn't help me.

Please help me to get out of this circle of upgrading and downgrading... Thanks in advance

1

There are 1 best solutions below

3
May.D On

So I've just read the sources from django-haystack 3.0 and there are several weird things.

First thing is that the using parameter is never used in the function definition (maybe its for subclasses, I didnt dig that far):

def index_queryset(self, using=None):
        """
        Get the default QuerySet to index when doing a full update.
        Subclasses can override this method to avoid indexing certain objects.
        """
        return self.get_model()._default_manager.all()

Back to your error, in the build_queryset method, the parameter using is passed to the function index_queryset not the queryset itself, so I can't see why it would raise an error.

Last thing is, I tested with both Django 2 and 3 projets, and using is always a method of queryset, not an argument, so I'm quite confused. Is your traceback from Django 3.2 and haystack 3.0 ?