Action that respects the filters in changeview_list

1
2
3
4
5
6
def publish(modeladmin,request,queryset):
    kwargs = {}
    for filter,arg in request.GET.items():
        kwargs.update({filter:arg})
    queryset = queryset.filter(**kwargs)
    queryset.update(published=True)

More like this

  1. Use dateutil's relativedelta to sort an arbitrary list of Django objects by date by cmcavoy 6 years, 2 months ago
  2. Export Related as JSON Admin Action by johnboxall 3 years, 10 months ago
  3. Dynamically create Django admin actions by pantsman 3 years, 5 months ago
  4. Return to a filtered changelist on change form save by richardbolt 2 years, 9 months ago
  5. Dynamically insert or append a value to an admin option, e.g. list_display or list_filter by frankban 1 year, 8 months ago

Comments

(Forgotten your password?)