So I’ve been working for a couple days now on setting up a pretty basic bulk edit action for my server that consists of selecting all of the objects you want to change a designated field on, being redirected to an intermediate page, entering a new integer value for the designated field, and then clicking accept to make the changes to all of the objects. I tried to use the bulk delete that comes pre-installed with all models as a template to make my action, form, and template for the intermediate page, and I don’t get any errors, but when I submit my changes on the intermediate page, I’m redirected to the objects list page and my action is not run again.
I’m not sure how to get the redirect from the template to correctly call my action after it returns, I’ve tried a lot of things and nothing seems to work. I’ll post the code and screenshots below: *my action definition:* def change_min_interval(self, request, queryset): form = None opts = self.model._meta app_label = opts.app_label if not self.has_change_permission(request): raise PermissionDenied using = router.db_for_write(self.model) if 'apply' in request.POST: form = self.ChangeMinIntervalForm() if form.is_valid(): new_interval = form.cleaned_data['new_interval'] rows_updated = queryset.update(min_interval=new_interval) plural = '' if rows_updated != 1: plural = 's' self.message_user(request, "Successfully changed min_interval to %s on %d node%s." % (new_interval, rows_updated, plural)) return None if len(queryset) == 1: objects_name = force_text(opts.verbose_name) else: objects_name = force_text(opts.verbose_name_plural) if not form: form = self.ChangeMinIntervalForm() context = dict( self.admin_site.each_context(request), app_label=app_label, title="Change min_interval", objects_name=objects_name, nodes=queryset, opts=opts, new_interval_form=form, ) request.current_app = self.admin_site.name return TemplateResponse(request, 'admin/change_min_interval.html', context) change_min_interval.short_description = "Change Minimum Interval" *my form definition:* class ChangeMinIntervalForm(forms.Form): new_interval = forms.IntegerField() *my template definition:* {% extends "admin/base_site.html" %} {% load i18n admin_urls %} {% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-min-interval-confirmation{% endblock %} {% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> › <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a> › <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst|escape }}</a> › {% trans 'Change min_interval' %}</div> {% endblock %} {% block content %} <p>Enter new minimum interval to apply:</p> <form action="" method="post"> {% csrf_token %}<div> {{ new_interval_form }} <p>The new minimum interval will be applied to:</p> <ul>{{ nodes|unordered_list }}</ul> <input type="hidden" name="action" value="change_min_interval" /> <input type="submit" name="apply" value="{% trans "Apply Minimum Interval" %}" /> <a href="#" onclick="window.history.back(); return false;" class="button cancel-link">Cancel</a></div></form> {% endblock %} *screenshots:* Selecting node to run the action on. <https://lh3.googleusercontent.com/-5GKogRSNLDc/Vjz8RVrl_gI/AAAAAAAAAZM/otn_UmIIYsM/s1600/Screen%2BShot%2B2015-11-04%2Bat%2B1.04.55%2BPM.png> Selecting new min_interval for the node <https://lh3.googleusercontent.com/-h5l3wdraFR8/Vjz8UpUuWEI/AAAAAAAAAZU/IQvc1zW9qsI/s1600/Screen%2BShot%2B2015-11-04%2Bat%2B1.05.09%2BPM.png> Lack of results after submitting the form. <https://lh3.googleusercontent.com/-fOFKFvejlOc/Vjz8XROM5aI/AAAAAAAAAZc/h4hGjeCTaEU/s1600/Screen%2BShot%2B2015-11-04%2Bat%2B1.05.15%2BPM.png> Shell outputs throughout this proccess. <https://lh3.googleusercontent.com/-5yyzyPlw6a0/Vjz8aGpTqiI/AAAAAAAAAZk/aSP1TZtX6d4/s1600/Screen%2BShot%2B2015-11-04%2Bat%2B1.05.33%2BPM.png> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/91d1b2f2-05bc-4f52-ac61-2fad972c5599%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.