Maybe I missing some step: I trying to set up the the automatic admin page form to edit a category tree builded with treebeard extension: #Model: class Categoria(AL_Node,Componente): immagine = fields.ImageWithThumbnailsField (upload_to=Componente.image_path + 'categorie/', thumbnail={'size': (100, 60),'options': ['crop', 'upscale'],}, help_text = Componente.image_help_text, blank=True,default=Componente.noimage_logo) parent = models.ForeignKey('self', related_name='children_set', null=True, db_index=True) node_order_by = ['data_creazione'] class Meta: verbose_name = 'Categoria' verbose_name_plural = 'Categorie'
but the I would exclude some elements from the foreign key choice widget as itself object id and its descendants: First I tried this to exclude the element that I editing: #admin.py class CategoriaForm(forms.ModelForm): class Meta: model = Categoria def __init__(self, *args, **kwargs): super(CategoriaForm,self).__init__(self, *args, **kwargs); self.fields['parent'].queryset = Categoria.objects.filter ('id'<>kwargs['instance'].id) but I get this error in the Categoria admin editing page: Exception Type: TypeError Exception Value: 'bool' object is not iterable Exception Location: D:\codice\workspace\django\django\db\models\sql \query.py in add_filter, line 1101 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---