def _edit(self, pk):
is_valid_form = True<EOL>pages = get_page_args()<EOL>page_sizes = get_page_size_args()<EOL>orders = get_order_args()<EOL>get_filter_args(self._filters)<EOL>exclude_cols = self._filters.get_relation_cols()<EOL>item = self.datamodel.get(pk, self._base_filters)<EOL>if not item:<EOL><INDENT>abort(<NUM_LIT>)<EOL><DEDENT>pk = self.datamodel.get_pk_value(item)<EOL>if request.method == "<STR_LIT:POST>":<EOL><INDENT>form = self.edit_form.refresh(request.form)<EOL>self._fill_form_exclude_cols(exclude_cols, form)<EOL>form._id = pk<EOL>if form.validate():<EOL><INDENT>self.process_form(form, False)<EOL>form.populate_obj(item)<EOL>try:<EOL><INDENT>self.pre_update(item)<EOL><DEDENT>except Exception as e:<EOL><INDENT>flash(str(e), "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>if self.datamodel.edit(item):<EOL><INDENT>self.post_update(item)<EOL><DEDENT>flash(*self.datamodel.message)<EOL><DEDENT>finally:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>is_valid_form = False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>form = self.edit_form.refresh(obj=item)<EOL>self.prefill_form(form, pk)<EOL><DEDENT>widgets = self._get_edit_widget(form=form, exclude_cols=exclude_cols)<EOL>widgets = self._get_related_views_widgets(<EOL>item,<EOL>filters={},<EOL>orders=orders,<EOL>pages=pages,<EOL>page_sizes=page_sizes,<EOL>widgets=widgets,<EOL>)<EOL>if is_valid_form:<EOL><INDENT>self.update_redirect()<EOL><DEDENT>return widgets<EOL>
Edit function logic, override to implement different logic
returns Edit widget and related list or None