'Edit function logic, override to implement different logic
returns Edit widget and related list or None'

def _edit(self, pk):

    is_valid_form = True
    pages = get_page_args()
    page_sizes = get_page_size_args()
    orders = get_order_args()
    get_filter_args(self._filters)
    exclude_cols = self._filters.get_relation_cols()
    item = self.datamodel.get(pk, self._base_filters)
    if (not item):
        abort(404)
    pk = self.datamodel.get_pk_value(item)
    if (request.method == 'POST'):
        form = self.edit_form.refresh(request.form)
        self._fill_form_exclude_cols(exclude_cols, form)
        form._id = pk
        if form.validate():
            form.populate_obj(item)
            try:
                self.pre_update(item)
            except Exception as e:
                flash(str(e), 'danger')
            else:
                if self.datamodel.edit(item):
                    self.post_update(item)
                flash(*self.datamodel.message)
            finally:
                return None
        else:
            is_valid_form = False
    else:
        form = self.edit_form.refresh(obj=item)
    widgets = self._get_edit_widget(form=form, exclude_cols=exclude_cols)
    widgets = self._get_related_views_widgets(item, filters={}, orders=orders, pages=pages, page_sizes=page_sizes, widgets=widgets)
    if is_valid_form:
        self.update_redirect()
    return widgets
