The query it produces is pretty close to what you'd expect though - apart from the extra column. The reason i'd like it to work is because i'm applying filters based on context using some complicated logic that sometimes applies the "none" method. Should I ticket this?
In terms of a quick hack, do you think substituting the "none" method for a "filter(pk__in=[])" would be ok? It works, but not sure if there may be any other side effects. E.g. I cant print the query (EmptyQuerySet exception). Anyways, I tried overriding the "none" method using a custom query set manager, but I can't for some reason. I can override other methods such as delete, but any application of "none" uses the inherited method. Why is this happening (code below)? 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? Thanks for the help guys. On Jul 26, 2:18 am, Ogi Vranesic <o...@redcor.ch> wrote: > Obviously the subquery has too many columns, namely > two: "error_test"."id", and "error_test"."name", > but you want that only "error_test"."id" is NOT in select > elements of the subquery. > I'm not even sure that your approch makes sense. > > Greetings, Ogi > > >Hi all, > >Just came across this error. > >class Test(models.Model): > > > name = models.CharField(max_length=20) > > > > >test = Test(name='bob') > >test.save() > >pks = Test.objects.none().values('pk').query > >print Test.objects.exclude(pk__in=pks) > >DatabaseError: subquery has too many columns > >The query: > >SELECT > > "error_test"."id", > > "error_test"."name", > >FROM > > "error_test" > >WHERE > > NOT ( > > "error_test"."id" > > IN ( > > SELECT > > "error_test"."id", > > "error_test"."name", > > FROM > > "error_test" > > ) > > ) > >Same thing happens when: > >print Test.objects.filter(pk__in=pks) > >Should this be ticketed? Should I tweak the app to ensure this doesn't > >happen? -- 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.