def get_media_form(model):
fields = model.admin_form_fields
if 'collection' not in fields:
# force addition of the 'collection' field, because leaving it out can
# cause dubious results when multiple collections exist (e.g adding the
# media to the root collection where the user may not have permission) -
# and when only one collection exists, it will get hidden anyway.
fields = list(fields) + ['collection']
return modelform_factory(
model,
form=BaseMediaForm,
fields=fields,
widgets={
'tags': widgets.AdminTagWidget,
'file': forms.FileInput(),
'thumbnail': forms.ClearableFileInput(),
})
评论列表
文章目录