Answering it to mark it resolved.
It was database config issue. I am having different settings file for different environment, and was having mismatch for database config in both files.
質問
I am using haystack with elasticsearch. I have build index data using rebuild_index command. But when I tried to search for object, its giving me following error:
"Object could not be found in database for SearchResult ' (pk=u'118')>'."
I have double checked in database, no records were deleted. But I am still getting this error.
Can anyone please help with it?
Thanks.
解決 2
Answering it to mark it resolved.
It was database config issue. I am having different settings file for different environment, and was having mismatch for database config in both files.
他のヒント
It looks like you are searching for your pk as a string and not an integer, not sure what your query looks like.
as integer, notice no quotes when defining pk_int:
pk_int = 118
Model.objects.get(pk = pk_int)
if your variable containing the pk is a string already, use int():
pk_string = '118'
Model.objects.get(pk = int(pk_string))
For anyone coming from a web search engine, if the accepted answer doesn't work for you, you can also try rebuilding the index:
./manage.py rebuild_index
I had the same error message as the OP, and rebuilding the index solved my issue.