Exemplo n.º 1
0
Arquivo: views.py Projeto: emef/web
def write(request):
    if "POST" == request.method:
        form = PostForm(request.POST)
        if form.is_valid():
            post = form.save()
            return HttpResponseRedirect("/" + post.title)
        else:
            form.non_field_errors = "Invalid"
    else:
        form = PostForm()
    return render("blog/write.html", {"form": form}, request)
Exemplo n.º 2
0
Arquivo: views.py Projeto: emef/web
def edit(request, title):

    # get the post for this title
    post = None
    try:
        post = Post.objects.get(title__iexact=title)
    except Post.DoesNotExist:
        return HttpResponseRedirect("/notfound")

    if "POST" == request.method:

        # save the post with changes from form
        form = PostForm(request.POST, instance=post)
        if form.is_valid():
            post = form.save()
            post.save()
            return HttpResponseRedirect("/%s" % (post.title))
        else:
            form.non_field_errors = "Invalid"

    else:
        form = PostForm(instance=post)
    return render("blog/write.html", {"form": form}, request)
Exemplo n.º 3
0
Arquivo: views.py Projeto: emef/web
def by_title(request, title):
    try:
        post = Post.objects.get(title__iexact=title)
        return render("blog/single.html", {"post": post}, request)
    except Post.DoesNotExist:
        return notfound(request)
Exemplo n.º 4
0
Arquivo: views.py Projeto: emef/web
def by_tag(request, tag):
    posts = Post.objects.filter(tags__keyword__iexact=tag)
    return render("blog/multi.html", {"posts": posts}, request)
Exemplo n.º 5
0
Arquivo: views.py Projeto: emef/web
def ovrundr(request):
    return render('home/ovrundr.html', {}, request)
Exemplo n.º 6
0
Arquivo: views.py Projeto: emef/web
def index(request):
    posts = get_recent_posts(10)
    return render("blog/multi.html", {'posts': posts}, request)
Exemplo n.º 7
0
Arquivo: views.py Projeto: emef/web
def index(request):
   pcount = get_unique_hits() 
   return render("stats/stats.html",
                 { "pcount": pcount },
                 request)