예제 #1
0
def create(request):
    if request.method == 'POST':
        title = request.POST['title']
        body = request.POST['body']

        post = Post(title=title, body=body)
        post.put()

        post_id = post.id()
        title_for_url = post.title_for_url()
        year = post.created_at.year
        month = post.created_at.month
        redirect_uri = '/' + str(year) + '/' + str(month) + '/' + str(title_for_url) + '/' + str(post_id)

        return HttpResponseRedirect(redirect_uri)
    else:
        return render_to_response('create.html',
                                  {},
                                  context_instance=RequestContext(request))