개인프로젝트입니다
✍ 학생 추가할 member_add.html 생성
<div class="regibox">
<h2>학생 정보</h2>
<form method="POST" action="member_add1">
{% csrf_token %}
<div>
<label for="name">이름: </label>
<input type="text" name="name" placeholder="이름을 입력하시오">
</div>
<div>
<label for="student_id">학번: </label>
<input type="text" name="student_id" placeholder="학번을 입력하시오">
</div>
<div>
<label for="major">학과: </label>
<input type="text" name="major" placeholder="학과를 입력하시오">
</div>
<br><br>
<button type="submit" value="submit">제출</button>
</form>
</div>
✍ html을 띄어줄 함수
def member_add(request):
return render(request,'member_add.html')
✍ 학생 추가할 member_add.html 생성
def member_add1(request):
member=Member()
member.name=request.POST['name']
member.student_id=request.POST['student_id']
member.major=request.POST['major']
member.save()
return redirect('member_add')