Fixes for django Q query rendering bug
Ensures that the QNodes haven't already been processed Fixes #185
This commit is contained in:
parent
cae3f3eeff
commit
5e8604967c
2 changed files with 6 additions and 2 deletions
|
|
@ -251,7 +251,8 @@ class QCombination(QNode):
|
|||
|
||||
def accept(self, visitor):
|
||||
for i in range(len(self.children)):
|
||||
self.children[i] = self.children[i].accept(visitor)
|
||||
if isinstance(self.children[i], QNode):
|
||||
self.children[i] = self.children[i].accept(visitor)
|
||||
|
||||
return visitor.visit_combination(self)
|
||||
|
||||
|
|
|
|||
|
|
@ -53,4 +53,7 @@ class QuerySetTest(unittest.TestCase):
|
|||
t = Template("{% for o in ol %}{{ o.name }}-{{ o.age }}:{% endfor %}")
|
||||
|
||||
d = {"ol": self.Person.objects.filter(Q(age=10) | Q(name="C"))}
|
||||
self.assertEqual(t.render(Context(d)), u'D-10:C-30:')
|
||||
self.assertEqual(t.render(Context(d)), 'D-10:C-30:')
|
||||
|
||||
# Check double rendering doesn't throw an error
|
||||
self.assertEqual(t.render(Context(d)), 'D-10:C-30:')
|
||||
Loading…
Add table
Add a link
Reference in a new issue