django admin action

Solutions on MaxInterview for django admin action by the best coders in the world

showing results for - "django admin action"
Niklas
30 Aug 2019
1from django.contrib import admin
2from myapp.models import Article
3
4def make_published(modeladmin, request, queryset):
5    queryset.update(status='p')
6make_published.short_description = "Mark selected stories as published"
7
8class ArticleAdmin(admin.ModelAdmin):
9    list_display = ['title', 'status']
10    ordering = ['title']
11    actions = [make_published]
12
13admin.site.register(Article, ArticleAdmin)
Yannik
16 Jan 2016
1# Add this code to admin.py
2#example : Published Article
3def make_published(modeladmin, request, queryset):
4    queryset.update(status='p')
5make_published.short_description = "Mark selected stories as published"