def save_related(self, request, form, *args, **kwargs):
"""
If the user has saved a gallery with a photo that belongs only to
different Sites - it might cause much confusion. So let them know.
"""
super(GalleryAdmin, self).save_related(request, form, *args, **kwargs)
orphaned_photos = form.instance.orphaned_photos()
if orphaned_photos:
msg = ungettext(
'The following photo does not belong to the same site(s)'
' as the gallery, so will never be displayed: %(photo_list)s.',
'The following photos do not belong to the same site(s)'
' as the gallery, so will never be displayed: %(photo_list)s.',
len(orphaned_photos)
) % {'photo_list': ", ".join([photo.title for photo in orphaned_photos])}
messages.warning(request, msg)
评论列表
文章目录