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 7447681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:41:23+00:00 2026-05-29T12:41:23+00:00

I have the following view in my views.py: def MoveSucessfulEntries(request): if request.method == ‘POST’:

  • 0

I have the following view in my views.py:

def MoveSucessfulEntries(request):
    if request.method == 'POST':
        objectsToBeDeleted = request.POST['imagesToBeRemoved']
        for objects in objectsToBeDeleted:
            print objects
            image = Image.objects.get(id=objects)
            SucessfulImage(emailAddress=image.emailAddress, image=image.image, caption=image.caption).save()
        return render_to_response('images/selectedSucessful.html')
    else:   
        images = Image.objects.all()
        return render_to_response('images/deleteUnsucessfulEntries.html', {'images': images})

imagesToBeRemoved are checkboxes on the HTML page that have the IDs of the images in the database which is generated like so:

<form method="POST" action="/image/selectSucessful">
    {% if images %}
        {% for image in images %}
            <input type="checkbox" name="imagesToBeRemoved" value="{{image.id}}" /> <image src="../media/{{image.image}}"> <br>
        {%endfor%}
        <input type="submit" value="Select" />
    {% else %}
        <p>No images are available.</p>
    {% endif %}
</form>

So I know that the ids returned from the form are in the database yet I keep getting the error object does not exist. Whats wrong with my code?

The stack trace says that the error is happening on:

image = Image.objects.get(id=objects)
  • 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-05-29T12:41:24+00:00Added an answer on May 29, 2026 at 12:41 pm

    The issue is you’re getting a string with

    objectsToBeDeleted = request.POST['imagesToBeRemoved']
    

    Since you’re POSTing multiple data what you want is:

    objectsToBeDeleted = request.POST.getlist('imagesToBeRemoved')
    

    Strings are iterable so you iterate over each of the digits, that is, if you want to delete an item with an id of 345, it’ll actually try to delete the items with ids of 3, 4, and 5.

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

Sidebar

Related Questions

I have the following view function in activities.views : def activity_thumbnail(request, id): pass I'm
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry
In views.py I have the following view which gets called when a new user
I have the following form in my /app/views/password_resets/new.html.erb view <% form_tag password_resets_path do %>
I have written a function having the following signature: def action_handler(request, model): This action_handler
The following in part of my view file def user_detail(request, username, template_name='auth/user_detail.html', extra_context=None): context
I have following view <asp:Content ID=Content2 ContentPlaceHolderID=MainContent runat=server> <h2>Tables <%=ViewData[RetriverName] %></h2> <%using (Html.BeginForm(ResfreshSelectedTables, Home))
In a branch spec, I have the following view: //depot/dev/t/a/g/... //depot/dev/t/r/g/... -//depot/dev/t/a/g/p/o*/... //depot/dev/t/r/g/p/... Perforce
I have the following in my view: <%using (Html.BeginForm()) {%> <% foreach (var item

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.