toastdriven/django-haystack — pull request #640 by jtratner (2012-09-07 03:23:57+00:00)
Title: Wrong SearchFieldError on ForeignKey/related without an attribute

Basically, though the code checks `current_object` for an attribute, it puts `repr(obj)` in the error message. It's a bit confusing when you are trying to figure out what's going on.

You could also fix this by using the original `self.model_attr` or by checking to see if `len(attrs) > 1` and then showing a more descriptive error message.

(e.g.:

```python
if current_object is obj:
raise SearchFieldError("The model %r has no model_attr %r." % (current_object, attr))
else:
raise SearchFieldError("The model %r has no model_attr %r. (Found while indexing %r for model_attr %r)" % (current_object, attr, obj, self.model_attr))
```
(though the second might be more easily handled with a format string...)
)