Django mptt model not linking to parent

112 Views Asked by At

Hello I am in the process of implementing a hierarchical location model. I have also created a form to be able to add locations while not using the admin interface. Tp do this I am using mptt's TreeNoeChoiceField. However when I select the correct parent and then submit the new location's parent defaults to none. I am unsure why this is happening and can't seem to find anyone else having similar issues.

forms.py

class Location Form(forms.ModelForm):
    parent = TreeNodeChoiceField(queryset=Location.objects.all())
    class Meta:
        model = Location
        fields = ("name", "description", "directions", "elevation", "latitude", "longitude")
1

There are 1 best solutions below

0
On

Everybody I was just being dumb. I forgot to put parent in the fields section