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.
