Exemple #1
0
def create_post(request):
    if request.method == 'POST':
        form = PostForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.save()
            return HttpResponseRedirect('/')
    else:
        form = PostForm()
    return render(request, 'post.html', {'form': form})
Exemple #2
0
def home(req):

    tmpl_vars = {
        'all_posts': Post.objects.reverse(),
        'form': PostForm()
    }
    return render(req, 'talk/index.html', tmpl_vars)
def create_post(request):
    if request.method == 'POST':
        form = PostForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.save()
            return HttpResponseRedirect('/')
    else:
        form = PostForm()
    return render(request, 'post.html', {'form': form})
Exemple #4
0
def home(request):
    tmpl_vars = {'form': PostForm()}
    return render(request, 'talk/index.html', tmpl_vars)
Exemple #5
0
def home(request):

    ctx = {'all_posts': Post.objects.reverse(), 'form': PostForm()}
    return render(request, 'talk/index.html', ctx)
Exemple #6
0
def home(request, template_name):
    all_posts = Post.objects.reverse()
    form = PostForm()
    return render(request, template_name, locals())