Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Callum Anderson
seal-mask
.a{fill-rule:evenodd;}techdegree
Callum Anderson
Data Analysis Techdegree Student 10,200 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

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