【发布时间】:2020-07-22 06:03:04
【问题描述】:
我正在玩 wagtail 并考虑将它用于网站。 在此过程中,我正在考虑通过 django-storages 和 wagtail-bakery 的组合为该网站提供服务。
目前,我正在尝试获取图像,并希望获得被视为“已发布”的鹡鸰图像列表。
我查看了 Image 模型的属性,但我没有看到任何可以定义图像是否发布的方法。
有没有办法确定图片是否已发布,或者获取属于已发布页面的图片列表?
>>> from wagtail.images.models import Image
>>>
>>> img = Image.objects.all()[0]
>>> for i in sorted(dir(img)):
... print(i)
...
DoesNotExist
Meta
MultipleObjectsReturned
__class__
__delattr__
__dict__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__getstate__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__module__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__setstate__
__sizeof__
__str__
__subclasshook__
__weakref__
_check_column_name_clashes
_check_constraints
_check_field_name_clashes
_check_fields
_check_id_field
_check_index_together
_check_indexes
_check_local_fields
_check_long_column_names
_check_m2m_through_same_relationship
_check_managers
_check_model
_check_model_name_db_lookup_clashes
_check_ordering
_check_property_name_related_field_accessor_clashes
_check_search_fields
_check_single_primary_key
_check_swappable
_check_unique_together
_do_insert
_do_update
_get_FIELD_display
_get_next_or_previous_by_FIELD
_get_next_or_previous_in_order
_get_pk_val
_get_unique_checks
_has_field
_meta
_perform_date_checks
_perform_unique_checks
_save_parents
_save_table
_set_file_hash
_set_pk_val
_state
admin_form_fields
check
clean
clean_fields
collection
collection_id
created_at
date_error_message
default_alt_text
delete
file
file_hash
file_size
filename
focal_point_height
focal_point_width
focal_point_x
focal_point_y
from_db
full_clean
get_autocomplete_search_fields
get_deferred_fields
get_file_hash
get_file_size
get_filterable_search_fields
get_focal_point
get_indexed_instance
get_indexed_objects
get_next_by_created_at
get_previous_by_created_at
get_rect
get_rendition
get_rendition_model
get_search_fields
get_searchable_search_fields
get_suggested_focal_point
get_upload_to
get_usage
get_willow_image
has_focal_point
height
id
indexed_get_content_type
indexed_get_parent
indexed_get_toplevel_content_type
is_editable_by_user
is_landscape
is_portrait
is_stored_locally
objects
open_file
pk
prepare_database_save
refresh_from_db
renditions
save
save_base
search_fields
serializable_value
set_focal_point
tagged_items
tags
title
unique_error_message
uploaded_by_user
uploaded_by_user_id
usage_url
validate_unique
width
【问题讨论】:
-
鹡鸰面包店不会为您处理这个吗?我用过一次,根据我的经验 wagtail-bakery 只包括使用过的图像再现。仅此而已。
-
我认为你是对的。我正在尝试使用 aws lambda/efs 进行非标准部署。在这个奇怪的用例中,wagtail-bakery 无法获取媒体,因为它需要一个文件系统对象而不是 django-storages s3 路径。我正在尝试这样做以解决此问题,并且不想公开所有未已发布的图像。
-
有一个未解决的问题。 github.com/wagtail/wagtail-bakery/issues/41
-
您可能想尝试将文件服务挂载为本地驱动器,并切换到默认的 Django 存储后端。
-
谢谢,是的,我正在尝试 EFS,所以我也许可以使用默认存储...我会研究一下。