Beispiel #1
0
def object_new(request):
    if request.method == "POST":
        o = ObjectForm(request.POST)
        if o.is_valid():
            o = o.save(commit=False)
            o.owner = request.user
            o.published_date = timezone.now()
            o.save()
            return redirect('object.views.object_list')
    else:
        o = ObjectForm()
    return render(request, 'object/edit.html', {'object': o})
Beispiel #2
0
def object_edit(request, pk):
    o = get_object_or_404(Object, pk=pk)
    if request.method == "POST":
        o = ObjectForm(request.POST, instance=o)
        if o.is_valid():
            o = o.save(commit=False)
            o.owner = request.user
            o.published_date = timezone.now()
            o.save()
            return redirect('object.views.object_view', pk=o.pk)
    else:
        o = ObjectForm(instance=o)
    return render(request, 'object/edit.html', {'object': o})
Beispiel #3
0
def object_new(request):
    if request.method == "POST":
        o = ObjectForm(request.POST)
        if o.is_valid():
            o = o.save(commit=False)
            o.owner = request.user
            o.published_date = timezone.now()
            o.save()
            return redirect('object.views.object_list')
    else:
        o = ObjectForm()
    return render(request, 'object/edit.html', {'object': o})
Beispiel #4
0
def object_edit(request, pk):
    o = get_object_or_404(Object, pk=pk)
    if request.method == "POST":
        o = ObjectForm(request.POST, instance=o)
        if o.is_valid():
            o = o.save(commit=False)
            o.owner = request.user
            o.published_date = timezone.now()
            o.save()
            return redirect('object.views.object_view', pk=o.pk)
    else:
        o = ObjectForm(instance=o)
    return render(request, 'object/edit.html', {'object': o})