def edit(request, article_id): if request.POST: title = request.POST['title'] author = request.POST['author'] cat_id = request.POST['cat_id'] publish_time = request.POST['publish_time'] content = request.POST['content'] a = Article.objects.filter(id=int(article_id)) a.update(article_title=title, article_author=author, publish_time=publish_time, article_content=content, article_cat_id_id=cat_id) return HttpResponseRedirect(reverse('article')) else: article_detail = function.get_article(article_id) cats = function.get_cats() return render_to_response('admin/article/article_editor.html', {'cats': cats, 'article': article_detail})
def index(request, template, cat_id=1, article_id=1): detail = function.get_detail() # 获取公司logo,标题简介等内容 cats = function.get_cats() # 获取所有分类 articles = function.get_articles(cat_id) # 获取某一分类的文章列表 cat = function.get_cat(cat_id) # 获取当前页面显示的分类 article = function.get_article(article_id) # 获取一篇文章的内容 allvar = { 'detail': detail, 'cats': cats, 'cat': cat, 'articles': articles, 'article': article, } return render_to_response(template, allvar)