问题
Our site has users who create PropertyPages, and they upload images about each Property. We want these images to not be shared with other Property or other pages, nor other users' content.
But the ImageChooserPanel has access to ALL images uploaded to the site, and newly uploaded images are available to any other user of that Chooser. I am looking for a way to associate images strongly with the individual page; we may only need the upload, not chose from existing images.
Is there a way to do this, perhaps by using a native Django mechanism? I'd still like to make them Orderable in the edit UI, the renditions, and optional storage to S3 like Wagtail Images.
I'm currently relating the multiple Photos to my PropertyPage like:
class PropertyPage(Page):
content_panels = [
InlinePanel("property_photo", min_num=1, max_num=100),
...]
class PropertyPhoto(Orderable):
page = ParentalKey(PropertyPage,
on_delete=models.CASCADE,
related_name="property_photo")
image = models.ForeignKey("wagtailimages.Image",
on_delete=models.CASCADE,
related_name="+")
panels = [ImageChooserPanel("image")]
Thanks for your help.
来源:https://stackoverflow.com/questions/65204618/limit-imagechooserpanel-to-children-of-current-page