@expose('/add/', methods=('GET', 'POST'))
    def add(self):
        if not self.can_create:
            abort(403)

        Form = self.get_add_form()
        if request.method == 'POST':
            form = Form()
            if form.validate_on_submit():
                try:
                    instance = self.save_model(self.model(), form, adding=True)
                    flash(gettext('New %(model)s saved successfully',
                          model=self.get_display_name()), 'success')
                    return self.dispatch_save_redirect(instance)
                except Exception, ex:
                    print traceback.format_exc()
                    if hasattr(self, 'session'):
                        self.session.rollback()
                    flash(gettext('Failed to add model. %(error)s',
                          error=str(ex)), 'error')

        else:
            try:
                form = Form(obj=self.model())
            except __HOLE__:
                raise Exception('The database model for %r should have an '
                                '__init__ with all arguments set to defaults.'
                                % self.model.__name__)

        return self.render(self.add_template, model=self.model, form=form)
dataset/ETHPy150Open syrusakbary/Flask-SuperAdmin/flask_superadmin/model/base.py/BaseModelAdmin.add