def get_object(self, queryset=None): key = self.kwargs.get('key') if not key: raise Http404 article = ArticleModel.get(Key(key)) if not article: raise Http404 return article
def get_initial(self): key = self.kwargs.get('key') if not key: raise Http404 self.key = Key(key) article = ArticleModel.get(self.key) if not article: raise Http404 return article.to_safe_dict()
def get_context_data(self, **kwargs): key = kwargs.get('key') if not key: raise Http404 article_key = Key(key) article = ArticleModel.get(article_key) if not article: raise Http404 kwargs['article'] = article.to_safe_dict() return super(ArticleView, self).get_context_data(**kwargs)
def form_valid(self, form): title = form.cleaned_data['title'] body = form.cleaned_data['body'] key = form.cleaned_data['key'] article = ArticleModel.get(Key(key)) article.update(title, body, self.request.user) article.put() return super(UpdateArticleView, self).form_valid(form)