Ejemplo 1: acción de administrador de django
from django.contrib import admin
from myapp.models import Article
def make_published(modeladmin, request, queryset):
queryset.update(status='p')
make_published.short_description = "Mark selected stories as published"
class ArticleAdmin(admin.ModelAdmin):
list_display = ['title', 'status']
ordering = ['title']
actions = [make_published]
admin.site.register(Article, ArticleAdmin)
Ejemplo 2: acción de administrador de django
# Add this code to admin.py
#example : Published Article
def make_published(modeladmin, request, queryset):
queryset.update(status='p')
make_published.short_description = "Mark selected stories as published"
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)