I'm trying to build a hierarchical tree and I am receiving the
following error to give a bind in my choice, someone could tell me in
what I'm missing:

[error]

TemplateSyntaxError at /plano_conta/listar/
Caught an exception while rendering: 'list' object has no attribute
'all'

[/error]


[model]

class ContaManager(models.Manager):
    def custom_query(self):
        cursor = connection.cursor()
        query = """SELECT node.id, REPEAT('---'::Varchar, (COUNT
(parent.nome)-1)::Integer) || ' ' || node.nome AS nome FROM
plano_conta_planoconta AS node, plano_conta_planoconta AS parent WHERE
node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.nome,
node.lft, node.id ORDER BY node.lft"""
        cursor.execute(query)
        return [(str(row[0]), row[1]) for row in cursor.fetchall()]


class PlanoConta(models.Model):
        nome = models.CharField(max_length=50, blank=True)
        lft = models.PositiveIntegerField()
        rgt = models.PositiveIntegerField()
        objects = ContaManager()

[/model]


[form]

class PlanoContaForm(ModelForm):
   id = IntegerField(required=False,widget=HiddenInput())
   nome = CharField(widget=TextInput(attrs={'class':'textInput
required'}), required=True)
   pai = ModelChoiceField(PlanoConta.objects.none(), empty_label=None)

    def __init__(self, *args, **kwargs):
        super(PlanoContaForm, self).__init__(*args, **kwargs)

        self.fields['pai'].queryset = PlanoConta.objects.custom_query
()

[/form]


how can I put a method in all my custom_query?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to