I think that was part of the idea around previously expecting only
Displayable subclasses to work - that guaranteed having a description field
as well as some accessible URL for the search result to point to.

As part of removing the restriction on subclassing Displayable, you'll see
in that commit above I reworked the search results template to not expect
anything in particular - perhaps someone just wants results to appear that
don't actually link to anything.

But yes, get_absolute_url is needed on the result for it to link somewhere.

On Wed, Oct 29, 2014 at 11:37 AM, Josh Cartmell <[email protected]>
wrote:

> Cool, thanks Steve.  To make this work I'm assuming you have to specify a
> get_absolute_url on the non Displayable models?
>
> On Tue, Oct 28, 2014 at 5:47 PM, Stephen McDonald <[email protected]> wrote:
>
>> You're right the docs don't match the advice I gave around Displayable.
>> Reading that, I took a much closer look at why subclassing Displayable is a
>> strict requirement for a model being searchable, and I don't think that
>> needs to be the case.
>>
>> I've made the following change which means that the example in the docs
>> and the code original posted in this thread should work:
>>
>>
>> https://github.com/stephenmcd/mezzanine/commit/cfc47424a09b51a92fc44eeca3af0ea58ff8ddf9
>>
>>
>>
>>
>> On Wed, Oct 29, 2014 at 2:03 AM, Josh Cartmell <[email protected]>
>> wrote:
>>
>>> Hey Steve, some of the confusion might come from the docs.  The last
>>> example here is almost identical to what Ernesto has done (i.e.
>>> search_fields specified on a non Displayable model):
>>> https://mezzanine.jupo.org/docs/search-engine.html#search-api
>>>
>>> Are the docs wrong in that instance, or is something else at play?
>>>
>>> On Mon, Oct 27, 2014 at 4:21 PM, Ernesto Palafox <
>>> [email protected]> wrote:
>>>
>>>> Thanks for your advice Stephen im trying to make a query but i get an
>>>> error:
>>>>
>>>> FieldError: Cannot resolve keyword u'name' into field. Choices are:
>>>> _meta_title, _order, children, content_model, created, description,
>>>> expiry_date, form, gallery, gen_description, homepage, id, in_menus,
>>>> in_sitemap, keywords, keywords_string, link, login_required, galeria,
>>>> pageimage, parent, publish_date, richtextpage, short_url, site, slide,
>>>> slug, status, title, titles, updated
>>>>
>>>> Its like my searchable fields arent recognized. How can i solve this?
>>>>
>>>> Thanks!
>>>>
>>>> El lunes, 27 de octubre de 2014 13:45:17 UTC-6, Stephen McDonald
>>>> escribió:
>>>>>
>>>>> The model you want searched needs to subclass Displayable - your Galeria
>>>>> model will do that, since it subclasses Page, which subclasses 
>>>>> Displayable,
>>>>> but your Item model does not.
>>>>>
>>>>> You need to stop and think about what a search result will look like
>>>>> and actually link to, which is the main idea around search being tied to
>>>>> the Displayable model - Displayable provides a title and url, which
>>>>> search results make use of.
>>>>>
>>>>> You might end up having your Item descriptions somehow feed into a
>>>>> searchable field on your Galeria model, and have it remain the thing that
>>>>> is searched and displayed as a distinct search result. Alternatively, it
>>>>> might be more suitable to make the Item mode subclass Displayable, with
>>>>> each Item having its own title (which would make your "name" field
>>>>> redundant) and url. Perhaps the url field on the Item model isn't strictly
>>>>> necessary, and you'll need to populate it with the parent Galeria
>>>>> instance's url somehow.
>>>>>
>>>>> You'll need to work out which approach best suits your case, and
>>>>> either way you'll probably need to implement some functionality in one of
>>>>> the model's "save" methods in order to populate some data in the other.
>>>>>
>>>>> Good luck!
>>>>>
>>>>> On Tue, Oct 28, 2014 at 5:37 AM, Ernesto Palafox <[email protected]
>>>>> > wrote:
>>>>>
>>>>>> Hi all, im new to mezzanine and I think its awesome.
>>>>>>
>>>>>> I am trying to follow the documentation http://
>>>>>> mezzanine.jupo.org/docs/search-engine.html to made searchable my
>>>>>> custon contentype
>>>>>>
>>>>>> My models.py looks more or less like this:
>>>>>>
>>>>>>
>>>>>> class Galeria(Page):
>>>>>> pass
>>>>>> class Item(models.Model):
>>>>>>
>>>>>> gallery = models.ForeignKey(Galeria, related_name="gallery")
>>>>>> name = models.CharField(max_length=30)
>>>>>> description_1 = RichTextField(blank=True,null=True)
>>>>>>  objects = SearchableManager()
>>>>>> search_fields = ("name", "description_1" )
>>>>>>
>>>>>>
>>>>>> I also have {%search_form "galeria.Item" %}.
>>>>>>
>>>>>>
>>>>>> However, when i try the search, it returns me nothing. ¿What am i
>>>>>> doing wrong?
>>>>>>
>>>>>>
>>>>>>  --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Mezzanine Users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Stephen McDonald
>>>>> http://jupo.org
>>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Mezzanine Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Mezzanine Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Stephen McDonald
>> http://jupo.org
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Mezzanine Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Mezzanine Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Stephen McDonald
http://jupo.org

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to