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 Django ORM Basic ORM Usage Delete

Karen Saunders
Karen Saunders
8,862 Points

Django ORM - can_spam filter

Can someone please point out where I've made an error in this challenge?

products/utils.py
from . import models


def can_spam(request):
    spam = models.Review.objects.filter(comment__icontains='http')
    spam.delete()
Karen Saunders
Karen Saunders
8,862 Points

It just say " Bummer! Make sure you delete Reviews that contain any form of "http" in the comment field."

1 Answer

Yosef Fastow
Yosef Fastow
18,526 Points

2 things to point out: 1) can_span is not a view so it doesn't need request. 2) also I ended off 'return spam.delete()'. I don't know if that needed but it doesn't hurt to try

def can_spam():
    spam = models.Review.objects.filter(comment__icontains='http')
    return spam.delete()
Yosef Fastow
Yosef Fastow
18,526 Points

Tried out the code both ways. You don't need to add return but request is the problem.

def can_spam():
    spam = models.Review.objects.filter(comment__icontains='http')
    spam.delete()