def add_to_category_and_subcategory(self, request, queryset): count = queryset.count() filecategory_form = FileCategoryForm(request.POST) if filecategory_form.is_valid(): for file in queryset: filecategory_form.update_file_cat_and_sub_cat(file) if count > 1: messages.success(request, _("Successfully updated Category/Sub Category of %(c)s files." % {'c':count})) elif count == 1: messages.success(request, _("Successfully updated Category/Sub Category of a file."))
def changelist_view(self, request, extra_context=None): extra_context = extra_context or {} filecategory_form = FileCategoryForm() extra_context.update({'filecategory_form': filecategory_form}) return super(FileAdmin, self).changelist_view(request, extra_context)