예제 #1
0
파일: views.py 프로젝트: cbajs12/djangosite
def update(request,board_id):
	email = request.session['email']
	userid = request.GET['id']
	if email != userid:
		return HttpResponseRedirect(reverse('board:lists'))
	else:	
		boards = Boards.objects.get(board_id=board_id)
		if request.method == 'POST':	
			form = WriteForm(request.POST,instance=boards)
			if form.is_valid():
				form.save()
				return HttpResponseRedirect(reverse('board:view',args=(board_id,)))
			else:
				print form.errors
		else:
			return render(request,'board/update.html',{"bd":boards})
예제 #2
0
파일: views.py 프로젝트: cbajs12/djangosite
def write(request):
	if request.method == 'POST':
		form = WriteForm(request.POST)
		if form.is_valid():
			email = request.session['email']
			info = Info.objects.get(email=email)
			nform = form.save(commit=False)
			nform.user_id = email
			nform.user_name = info.last_name
			nform.hits = 0
			nform.save()
			return HttpResponseRedirect(reverse('board:lists'))
		else:
			print form.errors
	else:
		return render(request,'board/write.html')