specify a queryset or a model to a handler

Issue #40 open
Jason Christa
created an issue

Sometimes it is convenient to specify a queryset rather than a model to the handler. For example if you only want to expose publish articles you don't want to use Articles.objects instead you would like to use Articles.published.

This seems easy to accomplish. Inside the BaseHandler class add:

{{{ def init(self): if hasattr(self, 'queryset'): self.model = self.queryset.model elif hasattr(self, 'model'): self.queryset = model.objects }}}

and replace most instances of self.model.objects with self.queryset.

The new statement would be

{{{ MyHandler(BaseHandler): allowed_methods = ('GET',) queryset = Articles.published }}}

Comments (1)

  1. Log in to comment