render_to edit_record html def edit_record request id record get_objec

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
@render_to("edit_record.html")
def edit_record(request, id):
record = get_object_or_404(Record, pk=id)
if request.method == 'POST':
form = EditRecord(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect("/testme/")
else:
return {'form': form}
if record.user == request.user:
initial = {'user': record.user, 'institution': record.institution}
form = EditRecord(initial=initial, instance=record)
return {'form': form}
else:
return HttpResponseRedirect("/")