DuVale / django-voting

Automatically exported from code.google.com/p/django-voting
Other
0 stars 0 forks source link

Patch for using custom managers with get_top #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, I've just made a patch for using get_top function passing a custom manager 
like this:

### models.py ###
from django.db import models

class MyManager(models.Manager):
    def get_query_set(self):
          return super(MyManager, self).get_query_set().filter(published=True)

class MyModel(models.Model):
    published = models.BooleanField()

    objects = models.Manager()
    published_objects = MyManager()

### views.py ####

from voting.models import Vote
from models import *

def view_best(request):
    my = Votes.objects.get_top(MyModel.published_objects)

    return my

I hope this will be useful ;)

Original issue reported on code.google.com by patrick....@gmail.com on 30 Dec 2009 at 10:48

GoogleCodeExporter commented 9 years ago
Added a correct patch, the first was wrong :)

Original comment by patrick....@gmail.com on 30 Dec 2009 at 11:11

Attachments: