1. Thomas Wanschik
  2. django-dbindexer-testapp
  3. Issues
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: {{{


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




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