예제 #1
0
파일: views.py 프로젝트: hvgo1/CS165MP
def addLocation(request):
    	if request.method == 'GET':
        	form = LocationForm()
    	else:
       	        form = LocationForm(request.POST)
                if form.is_valid():
			form.save()
            		return HttpResponseRedirect('locationlist')
    	return render(request,'crime/addlocation.html', {'form': form})
예제 #2
0
파일: views.py 프로젝트: hvgo1/CS165MP
def updateLocation(request,id):
    location = Location.objects.get(id=id)
    if request.method == 'GET':
        form = LocationForm(instance = location)
    else:
        form = LocationForm(request.POST)         
    	if form.is_valid():
		location.barangay = request.POST["barangay"]
		location.city = request.POST["city"]
		location.country = request.POST["country"]
		location.save()
        	return HttpResponseRedirect('locationlist')
    return render(request,'crime/updatelocation.html',{'location':location,'form':form,'action':'update/'+id})