コード例 #1
0
def add_blog_category():
    form = EditCategoryForm()

    if form.validate_on_submit():
        category = BlogCategory()

        category.name = form.name.data
        category.slug = form.slug.data
        category.description = form.description.data
        category.created_on = datetime.utcnow()

        db.session.add(category)
        flash('"{0}" has been saved'.format(category.name))

        return redirect(url_for('.blog_categories'))

    return render_template('admin/blog/categories/add_category.html', js='posts/add_edit_category', form=form)