Add admin action to generate missing encodings for a particular Media (#883)

* Add admin action to generate missing encodings for a particular Media
* Only regenerate the encodings that are missing
This commit is contained in:
Kyle Maas 2023-11-10 08:41:20 -05:00 committed by GitHub
parent 4829adf110
commit e7ce9ef5c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,12 @@ class MediaAdmin(admin.ModelAdmin):
def get_comments_count(self, obj):
return obj.comments.count()
@admin.action(description="Generate missing encoding(s)", permissions=["change"])
def generate_missing_encodings(modeladmin, request, queryset):
for m in queryset:
m.encode(force=False)
actions = [generate_missing_encodings]
get_comments_count.short_description = "Comments count"