def create_category(): form = CategoryForm(request.form, csrf_enabled=False) if form.validate_on_submit(): name = form.name.data category = Category(name) db.session.add(category) db.session.commit() flash('The category %s has been created' %name, 'success') return redirect(url_for('catalog.category', id=category.id)) if form.errors: flash(form.errors) return render_template('category-create.html', form=form)
def create_category(): form = CategoryForm(request.form, csrf_enabled=False) if form.validate_on_submit(): name = form.name.data category = Category(name) db.session.add(category) db.session.commit() flash('The category {} has been created'.format(name), 'success') return redirect(url_for('catalog.category', id=category.id)) if form.errors: flash(form.errors) return render_template('category-create.html', form=form)
def create_category(): form = CategoryForm(request.form) if form.validate_on_submit(): name = form.name.data category = Category(name) db.session.add(category) db.session.commit() flash('The category %s has been created' % name, 'success') return redirect(url_for('catalog.category', id=category.id)) if form.errors: flash(form.errors, 'danger') return render_template('category-create.html', form=form)
def create_category(): form = CategoryForm(request.form, csrf_enabled=False) if form.validate_on_submit(): name = request.form.get('name') category = Category(name) db.session.add(category) db.session.commit() flash('A new category named %s has been created' % name, 'success') return redirect(url_for('catalog.category', id=category.id)) if form.errors: flash("Some messages you type in need to be fixed.", 'danger') return render_template('category-create.html', form=form)
def create_category(): form = CategoryForm(request.form) if form.validate_on_submit(): name = form.name.data category = Category(name) db.session.add(category) db.session.commit() flash( _('The category %(name)s has been created', name=name), 'success' ) return redirect( url_for('catalog.category', id=category.id) ) if form.errors: flash(form.errors, 'danger') return render_template('category-create.html', form=form)