def get_form(self, request, obj=None, **kwargs):
if obj is not None and obj.parent is not None:<EOL><INDENT>self.previous_parent = obj.parent<EOL>previous_parent_id = self.previous_parent.id<EOL><DEDENT>else:<EOL><INDENT>previous_parent_id = None<EOL><DEDENT>my_choice_field = TreeItemChoiceField(self.tree, initial=previous_parent_id)<EOL>form = super(TreeItemAdmin, self).get_form(request, obj, **kwargs)<EOL>my_choice_field.label = form.base_fields['<STR_LIT>'].label<EOL>my_choice_field.help_text = form.base_fields['<STR_LIT>'].help_text<EOL>my_choice_field.widget = form.base_fields['<STR_LIT>'].widget<EOL>form.base_fields['<STR_LIT>'] = my_choice_field<EOL>if not getattr(self, '<STR_LIT>', False):<EOL><INDENT>self.known_url_names = []<EOL>self.known_url_rules = []<EOL>resolver = get_resolver(get_urlconf())<EOL>for ns, (url_prefix, ns_resolver) in resolver.namespace_dict.items():<EOL><INDENT>if ns != '<STR_LIT>':<EOL><INDENT>self._stack_known_urls(ns_resolver.reverse_dict, ns)<EOL><DEDENT><DEDENT>self._stack_known_urls(resolver.reverse_dict)<EOL>self.known_url_rules = sorted(self.known_url_rules)<EOL><DEDENT>form.known_url_names_hint = _(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>form.known_url_names = self.known_url_names<EOL>form.known_url_rules = self.known_url_rules<EOL>return form<EOL>
Returns modified form for TreeItem model.
        'Parent' field choices are built by sitetree itself.