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
Kiefer Jones
4,401 PointsDelete post in Flask Social Network
Trying to build on top of the Flask Social Network, want to delete posts, so far I've tried modifying the view_posts route, but am getting a "builtins.TypeError: delete_instance() missing 1 required positional argument: 'self' "
@app.route('/delete_post/<int:post_id>')
def delete_post(post_id):
posts = models.Post.delete_instance().where(models.Post.id == post_id)
if posts.count() == 0:
abort(404)
return redirect(url_for('index'))
<h2>
<a href="{{ url_for('delete_post', post_id=post.id) }}">Delete</a>
</h2>
1 Answer
Martin Cornejo Saavedra
18,132 PointsI don't know why are you using assignation when deleting, I don't think its neccesary.
I'd use this, but I've not tested it.
try: models.Post.where(models.Post.id == post_id).delete_instance() exception: abort(404)
kelv evod
Courses Plus Student 125 Pointskelv evod
Courses Plus Student 125 Pointssorry help here please !! even me have got such kind of problem