google-code-export / django-mptt

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

tree.add_related_count throws an AttributeError: 'str' object has no attribute 'extra' #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. node = ContentBox.objects.get(id=1)
2. tree_with_nodes =  ContentBox.tree.add_related_count(node.get_children(), 
ContentBox, "parent", "cat_count", cumulative=True)
3.

What is the expected output? What do you see instead?
the expected output is a list of child ContentBoxes which have a cat_count 
attribute containing the number of ContentBoxes associated with each of them

What version of the product are you using? On what operating system?
I use the latest version of django-mptt

Please provide any additional information below.

the output :

E
======================================================================
ERROR: test_project (wf.tests.TestProject)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/me/Projects/project/wf/tests.py", line 200, in test_project
    tree_with_nodes =  ContentBox.tree.add_related_count(node.get_children(), ContentBox, "parent", "nodes_count", cumulative=True)
  File "/usr/local/lib/python2.6/dist-packages/django_mptt-0.5.pre-py2.6.egg/mptt/managers.py", line 153, in add_related_count
    return queryset.extra(select={count_attr: subquery})
AttributeError: 'str' object has no attribute 'extra'

----------------------------------------------------------------------
Ran 1 test in 0.029s

FAILED (errors=1)

Original issue reported on code.google.com by dominikB...@gmail.com on 1 Dec 2010 at 3:16

GoogleCodeExporter commented 9 years ago
Migrated to https://github.com/django-mptt/django-mptt/issues/#issue/102

Original comment by craig.ds@gmail.com on 19 Dec 2010 at 1:10