I have models set up like this:
class Post(models.Model): name = models.CharField(max_length=10) class Comment(models.Model): post = models.ForeignKey(Post,related_name='comments') name = models.CharField(max_length=10)
And when I want to get all the comments from a post somepost.comments()
I get the following error:
>> somepost.comments() Traceback (most recent call last): File "<console>", line 1, in <module> File "a_path/django/db/models/fields/related.py", line 693, in __call__ manager = getattr(self.model, kwargs.pop('manager')) KeyError: 'manager'
It should be somepost.comments.all()
.
somepost.comments
returns a queryset. all
accesses the objects in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With