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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:35:40+00:00 2026-06-03T10:35:40+00:00

I’m a beginner, so forgive any stupidity in advance. I’m using Flask (and by

  • 0

I’m a beginner, so forgive any stupidity in advance. I’m using Flask (and by extension Jinja2) to create a simple web app — one that basically lets you type a movie into a web form, which adds it to a SQLite database. I’ve gotten Flask to very nicely iterate through all the movies in the database and print them to the page upon load.

I want to include a “Delete” button next to each movie. Getting the button to appear is simple. But I’m not sure how to tie the button back to the function delete_movie() such that it will delete the correct movie associated with the button pressed.

Since there will be a button next to each movie, the form element must be dynamically named, I’m guessing. But if it’s dynamically named, how do I pass the correct value back to the function? This is what I’ve got so far:

#movies.html
<div class=page>
    <h1>Movie List</h1>
    <ul class=movies>
    {% for movie in movies %}
        <li><h1>{{ movie.title }}</h1>
        <form action="{{ url_for('delete_movie') }}" method=post class=delete-movie><input type=submit value=Delete name=movie_to_delete"></form>
    {% endfor %}
    </ul>
</div>

#app.py
@app.route('/delete', methods=['POST'])
def delete_movie():
    g.db.execute('delete from movies where movie = ?', [request.form['movie_to_delete']])
    g.db.commit()
    return redirect(url_for('list_movies'))

Thanks in advance for any help!

  • 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-03T10:35:41+00:00Added an answer on June 3, 2026 at 10:35 am

    Just add a hidden input to every form with the element id/name that you want to delete as the value 🙂

    eg.

    <form action="{{ url_for('delete_movie') }}" method=post class=delete-movie>
      <input type=hidden value="{{ movie.name }}"name=movie_to_delete />
      <input type=submit />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.