1๐
I am having a similar issue. I would like to remove a node and all of its children.
Here is how I manage to do that:
class FolderForm(forms.ModelForm):
class Meta:
model = Folder
fields = ('name', 'parent')
def __init__(self, *args, **kwargs)
super(FolderForm, self).__init__(*args, **kwargs)
if self.instance is not None:
exclude_ids = [f.id for f in self.instance.get_descendants(
include_self=True)]
self.fields['parent'].queryset = self.fields['parent'].queryset \
.exclude(pk__in=exclude_ids)
๐คNatim
- [Django]-Django flush query caches
- [Django]-Django using curry to build formsets with custom form
- [Django]-How to modify the app name in Django admin's urls?
Source:stackexchange.com