Exemplo n.º 1
0
def add_goal(request):
    if request.method == 'POST':
        form = GoalForm(request.POST)
        if form.is_valid():
            form.save()
            goals_list = Goal.objects.all()
            return render_to_response('goals.html',{'goals':goals_list}, context_instance=RequestContext(request)) 
    else:
        form = GoalForm()
    return render_to_response('goals.html', {'form':form}, context_instance = RequestContext(request))
Exemplo n.º 2
0
def edit_goal(request, id_Goal):
    goal = Goal.objects.get(pk = id_Goal)
    if request.method == 'POST':
        form = GoalForm(request.POST, instance = Goal)
        if form.is_valid():
            form.save()
            goals_list = Goal.objects.all()
            return render_to_response('goals.html',{'goals':goals_list}, context_instance=RequestContext(request))
    else:
        form = GoalForm(instance = goal)
    return render_to_response('goals.html', {'form':form}, context_instance = RequestContext(request))