def __init__(self, *args, **kwargs):
        self.parent_pk = kwargs.pop('parent_pk', None)
        super(PageNodeForm, self).__init__(*args, **kwargs)

        self.fields['groups'].queryset = PageGroup.objects.all()

        # we just need to store these for later to set the key order
        page_field_names = self.fields.keys()

        self.node_field_names = []
        for field in PageNode._meta.fields:
            if field.editable and \
               field.name not in ['id', 'depth', 'numchild', 'path', 'slug']:
                self.node_field_names.append(field.name)

        additional_fields = forms.fields_for_model(
            PageNode, fields=self.node_field_names)
        self.fields.update(additional_fields)

        # if we have a node instance, initialise the page-related fields
        # with the appropriate values
        instance = kwargs.get('instance')
        if instance:
            for field_name in self.node_field_names:
                self.fields[field_name].initial = getattr(
                    instance.node, field_name)

        # update the field order for the page and node fields
        self.fields.keyOrder = self.node_field_names + page_field_names
dataset/ETHPy150Open tangentlabs/django-fancypages/fancypages/dashboard/forms.py/PageNodeForm.__init__/original