1 2 3 4 5 6 7 8 9 10 | def create_action(quality):
def action(modeladmin, request, queryset): queryset.update(quality=quality)
name = "mark_%s" % (quality,)
return (name, (action, name, "Mark selected as %s quality" % (quality,)))
class PackageAdmin(admin.ModelAdmin):
list_display = ('name', 'quality')
def get_actions(self, request):
return dict(create_action(q) for q in models.Quality.objects.all())
|
More like this
- Export Related as JSON Admin Action by johnboxall 3 years, 10 months ago
- Generic csv export admin action by dek 3 years, 9 months ago
- Simple Admin-button linking to Databrowse by magicrebirth 4 years ago
- Filter by taggit tags in the admin (Django 1.4) by albertorcf 8 months, 3 weeks ago
- Closure for FieldListFilter classes with custom sets of ranges by ssokolow 11 months ago
Comments
Thanks for the help.
#