def _add(self):
is_valid_form = True<EOL>get_filter_args(self._filters)<EOL>exclude_cols = self._filters.get_relation_cols()<EOL>form = self.add_form.refresh()<EOL>if request.method == "<STR_LIT:POST>":<EOL><INDENT>self._fill_form_exclude_cols(exclude_cols, form)<EOL>if form.validate():<EOL><INDENT>self.process_form(form, True)<EOL>item = self.datamodel.obj()<EOL>form.populate_obj(item)<EOL>try:<EOL><INDENT>self.pre_add(item)<EOL><DEDENT>except Exception as e:<EOL><INDENT>flash(str(e), "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>if self.datamodel.add(item):<EOL><INDENT>self.post_add(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>if is_valid_form:<EOL><INDENT>self.update_redirect()<EOL><DEDENT>return self._get_add_widget(form=form, exclude_cols=exclude_cols)<EOL>
Add function logic, override to implement different logic
returns add widget or None