Пример #1
0
    def post(self):
        form = BlogCategoryForm(self.request.POST)

        if form.validate():
            title = form.data["title"]
            slug = title.lower().replace(" ", "-")
            category = BlogCategory(title = title, slug = slug)
            category.put()

        self.redirect_to('admin-blog-categories')
Пример #2
0
    def post(self, category_id):
        form = BlogCategoryForm(self.request.POST)
        category = BlogCategory.get(long(category_id))

        if form.validate():
            slug = form.data["title"].lower().replace(" ", "-")
            form.populate_obj(category)
            category.put()

        return {
            "result": {
               "id": category.key().id(),
               "title": category.title,
               "slug": category.slug,
           }
        }