piccolo_api
piccolo_api copied to clipboard
Add media support to `PiccoloCRUD`
It would be good if we modified PiccoloCRUD, so it could accept a media_storage argument (like create_admin does in Piccolo Admin).
PiccoloCRUD(
Movie,
media_columns=[
LocalMediaStorage(Movie.poster, media_path='/srv/media/movie_posters/')
]
)
We could then add a new GET parameter called something like __media_urls, which then auto adds the URL to the response for accessing the media.
GET /1/?__media_urls
{
'id': 1,
'name': 'Star Wars',
'poster': 'some-file-abc-123.jpg',
'poster_url': '/media/some-file-abc-123.jpg',
}
Once this is in place, we can refactor Piccolo Admin slightly, so it passes the media_storage argument to PiccoloCRUD, and lets PiccoloCRUD do all of the heavy lifting.