Performing a ModelAdmin action in Django

133 views Asked by At

I'd like to be able to do something like:

# from the docs
def make_published(modeladmin, request, queryset):
    queryset.update(status='p')

But I'm not using the Django admin site - I just need to be able to do this type of functionality elsewhere in my site.

Where should something like this be defined? In a model manager?

1

There are 1 answers

2
Daniel Roseman On

I'm not quite sure why you want this.

An admin action is very specific, for use within the admin's changelist screen. There needs to be a special syntax, as you don't otherwise have control of that part of the application. If you want to perform an action on a queryset elsewhere on your site, you can just do it: you don't need any special way of doing so.