Héllo frocco,
2013/1/13 frocco <faro...@gmail.com> > > in models.py > > def get_categories(self): > return self.objects.filter('category_class <> "sales' > Use classmethod decorator<http://docs.python.org/2/library/functions.html#classmethod>to achieve that, like this: @classmethod def get_categories(cls): return cls.objects.filter(category_class='sales') I replaced self by cls since the first argument is now the class. Also the filter query is not correct, you have to use exclude<https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.exclude> . Mind the fact that this is not very django way of doing queries, using class methods or similar DAO pattern is not the most often used method to do querying with ORMs (AFAIK). Most of the time queries are inlined in the view or other code like this: def view(request): queryset = Category.objects.exclude(category_class='sales') context = Context({'title': 'Search', 'form': form, 'data': data}) return render_to_response('index.html', context) If you use very often this queryset you might want to create a manager for it, read the documentation regarding managers<https://docs.djangoproject.com/en/dev/topics/db/managers/> . > > in views.py > > data = Category.get_categories() > context = Context({'title': 'Search', 'form': form, 'data': data}) > return render_to_response('index.html', context) > this is not working. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.