Exemplo n.º 1
0
def entry_edit(request, year, month, day, slug, **kwargs):
    entry = Entry.objects.get(date_publish__year=year, date_publish__month=month, date_publish__day=day, slug=slug)
    if request.method == 'POST':
        form = EntryAdminForm(request.POST, instance=entry)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(entry.get_absolute_url())
    else:
        form = EntryAdminForm(instance=entry)

    return direct_to_template(request, 'fblog/entry_edit.html',{'form':form,'entry':entry})
Exemplo n.º 2
0
def entry_new(request, **kwargs):
    if request.method == 'POST':
        form = EntryAdminForm(request.POST)
        if form.is_valid():
            new_entry = form.save(commit=False)
            new_entry.author = request.user
            new_entry.save()
            return HttpResponseRedirect(reverse('blog_index'))
    else:
        form = EntryAdminForm()

    return direct_to_template(request, 'fblog/entry_edit.html',{'form':form})