コード例 #1
0
ファイル: views.py プロジェクト: eloyz/budget
def wish(request):
    from time_spent.forms import WishForm

    if request.method == "POST":
        form = WishForm(request.POST)
        if form.is_valid():
            wish = form.save(commit=False)
            wish.creator = request.user
            wish.save()

        return HttpResponseRedirect(reverse('net-income'))

    return render_to_response(
        'wish.html', {
            'form': WishForm()
        }, context_instance=RequestContext(request)
    )
コード例 #2
0
ファイル: views.py プロジェクト: eloyz/budget
def wish_change(request, pk):
    from time_spent.models import Wish
    from time_spent.forms import WishForm
    wish = get_object_or_404(Wish, pk=pk)

    if request.method == "POST":
        form = WishForm(request.POST, instance=wish)
        if form.is_valid():
            wish = form.save(commit=False)
            wish.creator = request.user
            wish.save()

        return HttpResponseRedirect(reverse('net-income'))

    form = WishForm(instance=wish)

    return render_to_response(
        'wish-change.html', {
        'wish': wish,
        'form': form,
        }, context_instance=RequestContext(request)
    )