Generic ModelChooserBlock for StreamField
See original GitHub issueI’d like to propose a ForeignBlock
or similar using models.ForeignKey
as it’s base for allowing integrations with other model clusters/models. It would most likely need to extend blocks.ChooserBlock
and shouldn’t be too difficult.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:13
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Developers - Generic ModelChooserBlock for StreamField -
I'd like to propose a ForeignBlock or similar using models.ForeignKey as it's base for allowing integrations with other model clusters/models.
Read more >How to use StreamField for mixed content
In addition to using the built-in block types directly within StreamField, it's possible to construct new block types by combining sub-blocks in various...
Read more >wagtail-modelchooser - PyPI
A plugin for Wagtail that provides a ModelChooserPanel and ModelChooserBlock for arbitrary models. Installing. Install using pip:
Read more >How to Add a Basic StreamField to your Wagtail CMS Page
Tutorial Summary. In this lesson we are going to learn how to add a basic StreamField to a a generic Wagtail CMS Page....
Read more >How to Add a Basic StreamField to your Wagtail CMS Page
In this lesson we are going to learn how to add a basic StreamField to a a generic Wagtail CMS Page. We'll create...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently there are two ways to manage non-
Page
models in Wagtail:When you register your model as a snippet it allows you to edit objects through the
Admin -> Snippets -> Your snippet name
menu and use nice chooser UI in the editing interface.However there are few cases when this behaviour doesn’t work really well:
Admin -> Snippets -> Your snippet name
and one in the Model Admin UI which is confusing. Generic model chooser should solve this issue.Taking into account the last point, it seems to me that the generic model chooser must not rely on Model Admin. I think, it should be something like the existing
register_snippet
but without exposing editing UI.I think the blocker to having a ModelAdmin-based chooser has been: ModelAdmin classes/instances know about the model they represent, but there’s no easy way to access a ModelAdmin class/instance from a model. Without moving to a ‘django-like’ registration method, where the relationships between models and ModelAdmin classes are stored in a central/reference-able place, I don’t see how we can circumvent this. But that has a tonne of other implications that need thinking through. That’s maybe a discussion for the developers board though, rather than here.