NoReverseMatch Error using Django + Haystack + Elasticsearch

56 views
Skip to first unread message

Aline C. R. Souza

unread,
Oct 14, 2016, 5:48:04 PM10/14/16
to Django users
Hello everybody,

I am having a issue using Django + Haystack + Elasticsearch to perform a website search.

I made a question on StackOverflow, but I had no satisfatory answer.

The problem is in this line:

by <a href="{% url 'blog.posts_by_author' post.author.pk %}">{{ post.author }}</a>

post.author.pk works well when called by several views, but it is not resolved when called by the search.

There is another way to get the pk of the author of the post?


Can someone help me? Please explain in details, because I am new in Django, and in haystack, elasticsearch...


Constantine Covtushenko

unread,
Oct 15, 2016, 3:43:21 AM10/15/16
to django...@googlegroups.com
Hi Aline,

I did not use Haystack but I am using ElastickSearch.
I carefully read you post on StackOverflow and see that search form returns author of the post without `pk` key defined.

Did you check what is returned by ElastickSearch?
May be your SearchForm returns exactly what Elastick stores in its index? I mean that post returned by SearchForm not the same as Post model? It can be dictionary or something?

Sorry I do not have time to build test app to check my idea.

You can easily set up a break point and check what are the posts inside your `post_search` view function.

Regards,
Constantine C.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fb151afb-35a8-4ac4-a9e4-69f4419568c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aline C. R. Souza

unread,
Oct 15, 2016, 8:33:22 AM10/15/16
to Django users, constantine...@gmail.com
Thank you for your time, Constantine. 

I gave up on following this path. 

I threw away everything that I did on this matter, and I followed the steps of this link: http://django-haystack.readthedocs.io/en/v2.5.0/tutorial.html

It took me some time to understand, but now it is working fine.

Thank you.

Em sábado, 15 de outubro de 2016 04:43:21 UTC-3, Constantine Covtushenko escreveu:
Hi Aline,

I did not use Haystack but I am using ElastickSearch.
I carefully read you post on StackOverflow and see that search form returns author of the post without `pk` key defined.

Did you check what is returned by ElastickSearch?
May be your SearchForm returns exactly what Elastick stores in its index? I mean that post returned by SearchForm not the same as Post model? It can be dictionary or something?

Sorry I do not have time to build test app to check my idea.

You can easily set up a break point and check what are the posts inside your `post_search` view function.

Regards,
Constantine C.
On Sat, Oct 15, 2016 at 12:48 AM, Aline C. R. Souza <linec...@gmail.com> wrote:
Hello everybody,

I am having a issue using Django + Haystack + Elasticsearch to perform a website search.

I made a question on StackOverflow, but I had no satisfatory answer.

The problem is in this line:

by <a href="{% url 'blog.posts_by_author' post.author.pk %}">{{ post.author }}</a>

post.author.pk works well when called by several views, but it is not resolved when called by the search.

There is another way to get the pk of the author of the post?


Can someone help me? Please explain in details, because I am new in Django, and in haystack, elasticsearch...


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages