示例#1
0
def addSkiva(request):
    if request.user.is_authenticated():
        vald_titel = request.POST['skiv_namn']
        text = request.POST['body_text']
        nySkiva = Post(titel = vald_titel, body = text)
        nySkiva.save()
        return HttpResponseRedirect('/')
    else:
        return HttpResponseRedirect('/login/')
示例#2
0
def addPost(request):
    if request.user.is_authenticated():
        if request.method != 'POST':
            form = BlogPost()
        else:
            form = BlogPost(request.POST)
            if form.is_valid():
                rubrik = form.cleaned_data['Titel']
                text = form.cleaned_data['Text']
                nyPost = Post(titel = rubrik, body = text)
                nyPost.save()
                return HttpResponseRedirect(reverse('minapp.views.index'))
    
        return render_to_response('addPost.html', locals())
    else:
        return HttpResponseRedirect('/login/')