Skip to content

Conversation

jhonvidal
Copy link

I am using django-elasticsearch-dsl version 7.4 and I want to contribute with this correction that caused the following problem:

TypeError at /en/search/

Unexpected queryset model (should be: <class 'myshop.models.Product'>, got: <class 'myshop.models.Product'>)

As a consequence and cause of this implementation:

def filter_queryset(self, queryset, keep_search_order=True):
    """
    Filter an existing django queryset using the elasticsearch result.
    It costs a query to the sql db.
    """
    s = self
    if s._model is not queryset.model:
        raise TypeError( …
            'Unexpected queryset model '
            '(should be: %s, got: %s)' % (s._model, queryset.model)
        )
    # Do not query again if the es result is already cached
    if not hasattr(self, '_response'):
    
    
    Verifying and debugging we observe that the variables are different :

ArcoLinux_2023-10-10_19-31-54

We observe that the models are not the same, it is because they are not showing the correct thing.

The solution is to add ._wrapped after ._model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant