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 trialIgor Protsenko
15,651 PointsIt seems like entry.where( expression ) doesn't work with integers
I wrote a little bit different code. The user have to specify a number of entry(which is correspond with the id of it in a database) in order to delete it. But somehow, the input of user doesn't work . Here's my code of del function
def delete_note():
'''Here you can delete a note'''
entrys=Entry.select()
print('Pick a note to delete, you just should specify the number')
for entry in entrys:
print(entry)
id_to_delete=int(input())
entry1=Entry.select().where(Entry.id == id_to_delete)
entry1.delete_instance()
view_note()
When i use pdb, that's what i get:
(Pdb) print(entry1)
<class '__main__.Entry'> SELECT "t1"."id", "t1"."content", "t1"."timestamp" FROM "entry" AS t1 WHERE ("t1"."id" = ?) [1]
1 Answer
Krzysztof Growinski
8,405 PointsIt's more likely that entry with ID that you selected does not exist.