Hello, I have a problem to add custom methods to my models. I found solution in django book but it does not work. Here is my code for models
class NewsManager(models.Manager):
def getLastNews(self):
return self.objects.order_by('-id')[:3]
class News(models.Model):
title=models.SlugField()
shortBody=models.CharField(max_length=250)
fullBody=models.TextField()
author=models.ForeignKey(User)
And now I run python manage.py shell
and type
from news.models import *
News.objects.getLastNews()
...
Attribute error Manager object have no attribute getLastNews
Where I did a mistake? Thx for any help. BTW this is good way to getting info from model and pass to view?