SearchQuerySet() contains real model object, how?

Skip to first unread message

Jul 25, 2017, 1:12:23 PM7/25/17
to django-haystack
>>> results=SearchQuerySet().all()
>>> results[0]
<SearchResult: kyc_connect_data_models.storypost (pk=u'429')>
>>> results[0].object
<StoryPost: <sarahh:First Channel POst>=QmVDXJvQXTZU9DWLy7kTAmyYwRvWao9PD98KPYvZ1JXRMG>

Using djangoHaystack, postgres as db, elasticsearch for search.
I have a 'StoryPost' model which I have indexed. SearchquerySet() returns the result whic is of type `SearchResult` which is fine.
But the object it contains is the actual model object, how come? Is it referring to the actual backend db 'postgres' is this case,
or have stored the exact replica in 'elasticsearch' db. 

Subhranath Chunder

Aug 22, 2017, 11:32:33 PM8/22/17
The search backend does store the model object.

Once the property `object` is accessed, it gets lazy loaded.

Refer to the official docs:

And the implementation of the same:

You received this message because you are subscribed to the Google Groups "django-haystack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Subhranath Chunder.
Reply all
Reply to author
0 new messages