TypeError: index_queryset() получил неожиданный аргумент ключевого слова using

      Django==3.2.5
django-haystack==3.0
pysolr==3.9.0

Solr = 8.9.0

Я следую руководству, как в https://django-haystack.readthedocs.io/en/master/tutorial.html, чтобы создать приложение Django с Solr.

При выполнении ./manage.py rebuild_index, Я получаю сообщение об ошибке:

       **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'** 

Я застрял в течение 3 дней, решая эту ошибку. Пытался понизить версию каждого из пакетов (Django, pysolr, haystack с solr 6.6, но мне это не помогло.

Пожалуйста, помогите мне выйти из этого круга обновлений и понижений ... Заранее спасибо

1 ответ

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

First thing is that the 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 ?

Другие вопросы по тегам