wagtail / wagtail-autocomplete

An Autocomplete edit handler for selecting Pages, Snippets, and more.
https://wagtail-autocomplete.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
120 stars 55 forks source link

`autocomplete_search_field` does not work with snippets #178

Open frague59 opened 9 months ago

frague59 commented 9 months ago

Hi,

I'm trying to use an AutocompletePanel to select a model instance from a snippet.

I've seen in the doc I can use the autocomplete_search_field to use a field NOT named title, here name

class SideDish(models.Model):
    name = models.CharField(max_length=255)

    class Meta:
        ordering = ('name',)

    panels = [...]

    autocomplete_search_field = "name"

class Menu(ClusterableModel):
    ...
    side_dishes = models.ManyToManyField(SideDish)

    ...

    panels = [
        ...
        AutocompletePanel("side_dishes")
        ...

This feature does not work, I've a django error.

Thanks for your help !

muvalika commented 7 months ago

During considering the "SideDish" model before the Menu model, you ensure that the SideDish model is available when creating the many-to-many relationship.