Beispiel #1
0
def new_article(request):
    # means add ariticle
    # add intro
    request.POST['intro'] = request.POST['content'][0:60] + '......'
    form = ArticleInfoForm(request.POST, request.FILES)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('gallery.html')
    return gallery(request)
Beispiel #2
0
def edit_article(request):
    article_id = request.POST['article_id']
    # means update article
    article = ArticleInfo.objects.get(id=article_id)
    # add intro
    request.POST['intro'] = request.POST['content'][0:60] + '......'
    form = ArticleInfoForm(request.POST, instance=article)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('gallery.html')
    return gallery(request)