There's quite a few use cases for blocks that link through to a handpicked list of objects such as images or products. Currently these are either hard-coded or defined using some add_to_class magic.
This could be wrapped up in a nice metaclass that can be used for these types of blocks providing a few helpful convenience functions on the model as well.
Ideally, the block definition would look something like this and the magic happens in it's metaclass:
This will create 8 foreign keys with field names image_1, image_2, etc. and provides a property images on the model that return the related models as list.
There's quite a few use cases for blocks that link through to a handpicked list of objects such as images or products. Currently these are either hard-coded or defined using some
add_to_class
magic.This could be wrapped up in a nice metaclass that can be used for these types of blocks providing a few helpful convenience functions on the model as well.
Ideally, the block definition would look something like this and the magic happens in it's metaclass:
This will create 8 foreign keys with field names
image_1
,image_2
, etc. and provides a propertyimages
on the model that return the related models as list.