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 Using Databases in Python Gettin' CRUD-y With It Delete An Entry

Ankit Bindal
Ankit Bindal
2,830 Points

entry is local variable.

the delete_item() function does not belong to the model. When I do entry.delete_instance(), should't it delete the local variable "entry". Why is it deleting the actual entry(I know that's what we want, but its not like I have passed a pointer to entry here)?

1 Answer

Josh Keenan
Josh Keenan
19,652 Points

The function gets the entry passed in as an argument, then the same argument is what is being deleted, the actual entry from the table is being passed into the function and then you delete it with .delete_instance().

Ankit Bindal
Ankit Bindal
2,830 Points

makes sense. Thanks