toastdriven/django-haystack — pull request #661 by eire1130 (2012-10-05 21:26:17+00:00)
Title: Allow for onetoone relationships for search index

Because hasattr will only evaluate the onetoone reverse relationship manager when the referenced object is present, I created a small work around to allow for drilldowns in the this way.

So, let's say you have

class Address(Model):
addr = OneToOneField(Business)
city = some_char_field

With the above change, you can now do something like (where object = Business):

city = indexes.CharField(model_attr='address__city', default='', null=True)

However, if that particular business does not have an address the above code change will allow for the default of empty string to be created in the index.