Issue #1 new

run_query() should be a model Manager method

Markus Gattol
created an issue

run_query() in myapp/views.py should be a method on a Manager which is then attached to the model in question (e.g. MyModel), basically overriding the default Manager.

managers.py: {{{

!python

class MyModelManager(models.Manager): def run_query(name, month): result = MyModel.objects.filter(nameiexact=name, last_modifiedmonth=month) return result }}}

models.py:

{{{

!python

from django.db import models from managers import MyModelManager

class MyModel(models.Model): name = models.CharField(max_length=64) last_modified = models.DateTimeField(auto_now=True) objects = MyModelManager() }}}

Comments (4)

  1. Log in to comment