django-nonrel / nonrel-search

A port of gae-search using django-nonrel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when no ranking field is provided

mateuszmrozewski opened this issue · comments

    if rank_descending:
        sorted_ranked_query_result_set = sorted(dedup_query_result_list, 
                                                key=lambda result: (result.__partial_match_search__primary_rank,
                                                getattr(result, ranking_field)), reverse=True)
    else:
        sorted_ranked_query_result_set = sorted(dedup_query_result_list, 
                                                key=lambda result: (-result.__partial_match_search__primary_rank,
                                                getattr(result, ranking_field)))

This part of code raises execption on getattr() when no ranking_field is provided. Considering the doc and function arguments this should be a valid usage.