Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9176215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:03:53+00:00 2026-06-17T17:03:53+00:00

In my Django app I want to implement an intermediate page which asks for

  • 0

In my Django app I want to implement an intermediate page which asks for confirmation before executing a specific admin action. I took this post as an example.

I used the existing delete_confirmation.html template as a departing point and partially got it working. The confirmation page is shown and the selected objects are displayed. However my admin action is never called after clicking “Yes, I’m sure”.

In my admin.py I have:

def cancel_selected_bookings(self, request, queryset):
    """
    Cancel selected bookings.
    """
    if request.POST.get("post"):
        for booking in queryset:
            booking.cancel()
            message = "Booking %s successfully cancelled." % booking.booking_id
            messages.info(request, message)
    else:
        context = {
            "objects_name": "bookings",
            'title': "Confirm cancellation of selected bookings:",
            'cancellable_bookings': [queryset],
            'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
        }
        return TemplateResponse(request, 'admin/bookings/confirm_cancel.html', context, current_app=self.admin_site.name)

In my template I have (a clipping of the full template):

        <div class="grp-group">
            <h2>
                {% blocktrans %}
                    Are you sure you want to cancel the selected {{ objects_name }}?
                {% endblocktrans %}
            </h2>
            {% for cancellable_booking in cancellable_bookings %}
                <ul class="grp-nested-list">{{ cancellable_booking|unordered_list }}</ul>
            {% endfor %}
        </div>
        <form action="" method="post">{% csrf_token %}
            <div id="submit" class="grp-module grp-submit-row grp-fixed-footer">
                {% for obj in queryset %}
                    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}" />
                {% endfor %}
                <input type="hidden" name="action" value="cancel_selected_bookings" />
                <input type="hidden" name="post" value="yes" />
                <ul>
                    <li class="grp-float-left"><a href="." class="grp-button grp-cancel-link">{% trans "Cancel" %}</a></li>
                    <li><input type="submit" value="{% trans "Yes, I'm sure" %}" class="grp-button grp-default" /></li>
                </ul>
                <input type="hidden" name="post" value="yes" />
            </div>
        </form>

EDIT:

I found one problem in the above template. The lines:

{% for obj in queryset %}
  <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}" />
{% endfor %}

need to be replaced by:

{% for cancellable_booking in cancellable_bookings %}
  <input type="hidden" name="{{ action_checkbox_name }}" value="{{ cancellable_booking.id }}" />
{% endfor %}

For some mysterious reason however, the value of the hidden fields isn’t being set by {{cancellable_booking.id}}. When I hard code that with an existing id it all works as expected. What am I doing wrong??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:03:54+00:00Added an answer on June 17, 2026 at 5:03 pm

    This will work:

    In the action method:

    context = {
        'objects_name': 'bookings',
        'title': 'Confirm cancellation of selected bookings:',
        'cancellable_bookings': [queryset],
        'ids': queryset.values_list("id"),
        'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
    }
    

    In the template:

    {% for id in ids %}
        <input type="hidden" name="{{ action_checkbox_name }}" value="{{ id.0|unlocalize }}" />
    {% endfor %}
    

    Not sure why iterating the queryset doesn’t work but alas…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a reusable django app, which I want to make configurable by
So, I have created a django app here: http://fpaste.org/bkFf/ without using django-admin. I want
I want to serve my Django app the current time which clients will parse
I'm writing my first Django app and want to create a header model which
I have a Django app. When logged in as an admin user, I want
In my django App on the login page i want to have a request
I want to start developing a django app on heroku which uses the postgresql
I want to integrate photologue with my Django app and use it to display
I want to install a django-app without PIP. I'm using virtualenv with django. The
HI I have a django application running on app engine and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.