def get(self, pid): pid = int(pid) entity = models.Post.get_by_id(pid) ctx = context.default ctx['title'] = 'Post Modify' ctx['form'] = PostForm(instance=entity).as_p() html = kit.render(ctx, 'admin', 'postform.html') self.response.out.write(html)
def post(self, pid): entity = models.Post.get_by_id(int(pid)) form = PostForm(data=self.request.POST, instance=entity) if form.is_valid(): entity = form.save(commit=False) entity.put() self.redirect('/admin/post/edit/' + pid) else: ctx = context.default ctx['title'] = 'Post Modify' ctx['form'] = form.as_p() html = kit.render(ctx, 'admin', 'postform.html') self.response.out.write(html)
def post(self): data = PostForm(data=self.request.POST) if data.is_valid(): # Save the data, and redirect to the view page entity = data.save(commit=False) entity.put() pid = entity.key().id() self.redirect('/admin/post/edit/' + str(pid)) else: ctx = context.default ctx['title'] = 'Post Modify' ctx['form'] = data.as_p() html = kit.render(ctx, 'admin', 'postform.html') self.response.out.write(data)
def get(self): html = kit.render(context.default,'admin','home.html') self.response.out.write(html)
def get(self): ctx = context.default ctx['title'] = 'Post Modify' ctx['form'] = PostForm().as_p() html = kit.render(ctx, 'admin', 'postform.html') self.response.out.write(html)