Sorry to ask such a seemingly silly question, but how do I use
TreeNodeChoiceField in a ModelForm. To create a new node, I created a
ModelForm, and, like other ModelForms, I thought I could just override
the normal form widget. Here are my classes

class Folder(models.Model):
        parent = models.ForeignKey('self', null=True, blank=True,
related_name='children')
        name = models.CharField(max_length=20, unique=True)

class FolderForm(ModelForm):
        parent = TreeNodeChoiceField(queryset=Folder.tree.all(),
level_indicator=u'+--')

        class Meta:
                model=Folder

I get the error AttributeError: type object 'Folder' has no attribute
'tree'

If I move that statement to the Model class, I don't get the error,
but I can't use that 'tree' Manager.

if I change Folder.tree.all() to
Folder.objects.all().order_by('tree_id') it works mostly well, but
doesn't display the tree nicely like tree.all is supposed to. The docs
are a little ambiguous on the usage of this form field.

Any thoughts on a) how I can use tree manager appropriately or b) hack
it so that I get a queryset that mimics tree.all()?

-- 
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.

Reply via email to