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 trialDaniel Still
10,532 PointsDjango Challenge Task - Deleting Reviews
Here's the question...
"We're starting to get a lot of advertisement spam in our reviews. We're going to implement a better solution later, but for now, write a function named 'can_spam' that selects all of the 'Review(s)' where the comment field contains the string "http" and then delete them."
Here's my answer...
"from . import models
def can_spam(): http = Review.objects.filter(comment__icontains="http") http.delete()"
I cannot figure out what I did wrong. Any help would be massively appreciated. :)
from . import models
def can_spam():
http = Review.objects.filter(comment__icontains="http")
http.delete()
2 Answers
Ryan S
27,276 PointsHi Daniel,
Your code is basically correct. You just made a small error regarding the models import. Since you are importing the entire module, the model is accessed by using models.Review
, rather than just Review
.
from . import models
def can_spam():
http = models.Review.objects.filter(comment__icontains="http")
http.delete()
Daniel Still
10,532 PointsThanks mate!