def get_needful_files(self):
needful_files = []<EOL>for model in self.models():<EOL><INDENT>media_fields = []<EOL>for field in self.model_file_fields(model):<EOL><INDENT>media_fields.append(field.name)<EOL><DEDENT>if media_fields:<EOL><INDENT>exclude_options = {media_field: '<STR_LIT>' for media_field in media_fields}<EOL>model_uploaded_media = model.objects.exclude(**exclude_options).values_list(*media_fields)<EOL>needful_files.extend(model_uploaded_media)<EOL><DEDENT><DEDENT>return set(chain.from_iterable(needful_files))<EOL>
Returns set of media files associated with models.
Those files won't be deleted.