How to add a filtersearch option to a foreign key dropdown in Wagtail admin? - Stack Overflow

I have a Django foreign key field in my Wagtail admin panel that references the Faculty model. However,

I have a Django foreign key field in my Wagtail admin panel that references the Faculty model. However, when selecting a faculty for a course, the dropdown list does not provide a search or filter option.

Current code:

faculty = models.ForeignKey("Faculty", on_delete=models.CASCADE, related_name="courses") FieldPanel("faculty"),

This generates a basic dropdown list in the Wagtail admin panelbasic, but I need a searchable dropdown like this: need like this

What I need

A filter/search feature in the dropdown list when selecting a faculty in Wagtail admin.

Preferably a select2-style search box or any built-in Wagtail solution.

What I tried:

I looked into using FieldPanel, but I’m not sure how to make it searchable. Should I use AutocompletePanel, or is there another approach?

Any help would be appreciated!

I have a Django foreign key field in my Wagtail admin panel that references the Faculty model. However, when selecting a faculty for a course, the dropdown list does not provide a search or filter option.

Current code:

faculty = models.ForeignKey("Faculty", on_delete=models.CASCADE, related_name="courses") FieldPanel("faculty"),

This generates a basic dropdown list in the Wagtail admin panelbasic, but I need a searchable dropdown like this: need like this

What I need

A filter/search feature in the dropdown list when selecting a faculty in Wagtail admin.

Preferably a select2-style search box or any built-in Wagtail solution.

What I tried:

I looked into using FieldPanel, but I’m not sure how to make it searchable. Should I use AutocompletePanel, or is there another approach?

Any help would be appreciated!

Share Improve this question asked Mar 3 at 2:25 pavipavi 131 silver badge2 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

If you register your Faculty model as a snippet, FieldPanel will load the Snippet Chooser, which has a search box. You can then tweak the search by specifying the search fields and autocomplete fields for the Faculty model.

This is how the chooser looks like:

See Registering snippets and Making snippets searchable

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745112193a4611913.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信