Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TypeError unexpected query set model, compare correct object type, for version 7.4 #464

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant