Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask with SQLAlchemy Basics Connecting to a Database with SQLAlchemy Read, Update, Delete

Callum Anderson
Callum Anderson
9,719 Points

Ignored redirect in Delete route, any solutions? | SQLAlchemy & Flask

I've been successful so far with this course and enjoying it a lot!

I am having trouble figuring out a solution to getting the Delete commit to work as what it seems like after I trigger the db.delete & commit and next in line would be the redirect to the location I requested, it instead ignores the redirect and is stuck on the route URL and hits me with a 404 and the action unsuccessful.

Tried a few things on my own to see if I could get it to recognise it but nothing resolved. I'm working locally so have included a snapshot of everything just in case. Any ideas would be amazing!

Workspace: https://w.trhou.se/0o4afmzd9r

1 Answer

Mel Rumsey
.a{fill-rule:evenodd;}techdegree seal-36
Mel Rumsey
Treehouse Staff

Hey Callum Anderson!

I took a look at your code and the issue is coming from the HTML route on the delete button. You currently have url_for('delete_pet', id=pet_id) so it is getting invalid information passed in as the id. We are wanting the id to be equal to pet.id. That should solve the issue, but let me know if you are still stuck!

Keep up the great work

Callum Anderson
Callum Anderson
9,719 Points

Wow thank you! Can't believe I missed that