Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Confused about the delete route in my blueprint

So I'm making a book tracking application based off the flask tutorial with a few extra features (like allowing the user to input their current page and calculating a completion status)

Right now, my delete function is acting funny. The blog delete function takes me to a route
"POST /3/delete HTTP/1.1"
My version returns
"POST /anonymous/to%20be%20deleted/update HTTP/1.1"
Notice how it the url_for function builds the route for update instead?
This is my book.delete function I have in the book blueprint....

@bp.route("/<book_author>/<book_title>/delete", methods=('POST',))
def delete(book_author, book_title):

#updated_book = get_author_book(book_title, book_author)
book_id = returnIdFromTitleAndAuthor(book_title, book_author)

print("book_id currently is: " + book_id['id'])

if book_id is None:
flash("No book of that title + author to delete.")

db = get_db()
db.execute("DELETE FROM books WHERE books.id = ?", (book_id['id'],))
db.commit()

#print("Book is outta here")
flash("Book Deleted")
return redirect(url_for("book.index"))

None of the print statements are showing, meaning the function isn't being called. Here is

/r/flask
https://redd.it/1emtg60