On 27 juil, 06:27, gs794 <gregs...@gmail.com> wrote: > Hi all, > > I'm having trouble overriding QuerySet.none() (code below)... Works > if I rename the method to almost anything but "none". > > class QuerySetManager(models.Manager): > def get_query_set(self): > return self.model.QuerySet(self.model) > def __getattr__(self, name): > return getattr(self.get_query_set(), name) > > class NewNoneQuerySet(models.query.QuerySet): > def none(self): > print 'NewNone\n\n\n\n' > return self.filter(pk__in=[]) > > class TestNone(models.Model): > name = models.CharField(max_length=20) > objects = QuerySetManager() > class QuerySet(NewNoneQuerySet): > pass > > TestNone.objects.none() > > No output of 'NewNone\n\n\n\n'... Using the inherited method in other > tests... Is there something special about the none method?
Django is open-source, so you can read the source and find out by yourself why your code doesn't work as expected (I just did, and took me about 2 minutes). FWIW, you want to have a look at how Manager.none is implemented (in / django/db/manager.py) HTH. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.