Esempio n. 1
0
def trip_add(request):
    if request.method == 'POST': 
        form = TripForm(request.POST) 
        if form.is_valid(): 
            form.save()
            return HttpResponseRedirect('/') 
    else:
        form = TripForm()

    variables = RequestContext(request, {
        'form': form
    })
    
    return render_to_response('form.html', variables)    
Esempio n. 2
0
def trip_edit(request,trip_id):
    trip = get_object_or_404(Trip, pk=trip_id)
    if request.method == 'POST': 
        form = TripForm(request.POST, instance=trip ) 
        if form.is_valid(): 
            form.save()
            return HttpResponseRedirect('/') 

    else:
        form = TripForm(instance=trip ) 

    variables = RequestContext(request, {
        'form': form
    })
    
    return render_to_response('form.html', variables)