Debug show me that:
comments = Comment.get_for_intention(id)
is:
{QuerySet} Unable to get repr for class ‘django.db.models.query.QuerySet’
Comment model:
class Comment(models.Model):
user = models.ForeignKey(User)
intention = models.ForeignKey(Intention)
text = models.TextField()
created = models.DateTimeField(default=datetime.datetime.now())
@staticmethod
def get_for_intention(intention_id):
return Comment.objects.filter(intention=intention_id)[:10]
I have no idea what I am doing wrong. Could someone give me any advice?
I think problem is because of intention. it is foreign key and you want to use all intention object.
You should use
if you want to take comments only you dont have to define get_fot_intention and you dont have to use intention_id , just use intention object. You can use this for example:
but you have to slug field in intention.