[Django]-In django-haystack, how can I use subclasses of models?

3👍

{% if device.manufacturer %}
{{ device.manufacturer }}
{% endif %}

… the Haystack tutorial is a bit confusing on this subject (you don’t actually have to use a text-file template, for one) but the basic idea is that Haystack’s engine goes to town on whatever text data is in this template.

… Actually, it goes to town on whatever is in the response you send it, but if you’ve got the template set up you can use whatever Django template logic you want in there.

(note that the if template tag was a bit of a dog’s breakfast prior to Django 1.2; if you’re stuck on an earlier Django version you may have to tweak the syntax, but the principle is the same.)

Leave a comment