orangespaceman / phx

0 stars 1 forks source link

Fix error when highlighting search results #104

Closed lachiemurray closed 2 weeks ago

lachiemurray commented 2 weeks ago

Fixes:

...
  File "/home/phx/phx/env/lib/python3.10/site-packages/django/template/base.py", line 737, in resolve
    new_obj = func(obj, *arg_vals)
  File "/home/phx/phx/phx/phx/templatetags/highlight.py", line 13, in highlight
    return full_text.replace(search_term, replacement_text)

Exception Type: AttributeError at /results/
Exception Value: 'NoneType' object has no attribute 'replace'
Raised during: results.views.ResultsListView

Problem is the content of the "results" field can now be None so when we try to highlight parts of it which match the search query it failed.

Note: https://github.com/orangespaceman/phx/pull/103 would also have fixed because with that change we no-longer render the results field if it's None but this is a bit more explicit