Django Как зарегистрировать членство на другой странице
Я студент, который изучает Django. Если нажать кнопку OK на странице регистрации, то регистрация завершена! Я хотел бы поместить кнопку подтверждения в другой html и сохранить то, что я ввел на странице членства, возможно ли это?
Подводя итог, я хотел бы переместить кнопку моего членства в Different html, чтобы мое членство могло быть завершено.
register.html
<form method="post" class="post-form">
{% include "accounts/form_errors.html" %}
{% csrf_token %}
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label"><b>이름</b></label>
<div class="col-sm-10">
<input type="text" class="form-control" name="name" id="name"
value="{{ form.name.value|default_if_none:'' }}">
</div>
</div>
<div class="form-group row">
<label for="username" class="col-sm-2 col-form-label"><b>아이디</b></label>
<div class="col-sm-10">
<input type="text" class="form-control" name="username" id="username"
value="{{ form.username.value|default_if_none:'' }}">
</div>
</div>
<div class="form-group row">
<label for="password1" class="col-sm-2 col-form-label"><b>비밀번호</b></label>
<div class="col-sm-10">
<input type="password" class="form-control" name="password1" id="password1"
value="{{ form.password1.value|default_if_none:'' }}">
</div>
</div>
<div class="form-group row">
<label for="password2" class="col-sm-2 col-form-label"><b>비밀번호 확인</b></label>
<div class="col-sm-10">
<input type="password" class="form-control" name="password2" id="password2"
value="{{ form.password2.value|default_if_none:'' }}">
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-sm-2 col-form-label"><b>전화번호</b></label>
<div class="col-sm-10">
<input type="text" class="form-control" name="phone" id="phone"
value="{{ form.phone.value|default_if_none:'' }}">
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-2 col-form-label"><b>이메일</b></label>
<div class="col-sm-10">
<input type="text" class="form-control" name="email" id="email"
value="{{ form.email.value|default_if_none:'' }}">
</div>
</div>
<button type="submit" style="background: #637B46; float: right; border: white" class="btn btn-primary"><b>가입하기</b></button>
</form>
register/views.py
def register(request):
if request.method == 'POST':
member_form = RegisterForm(request.POST)
if member_form.is_valid():
new_member = member_form.save(commit=False)
new_member.set_password(member_form.cleaned_data['password2'])
new_member.save()
return render(request, 'accounts/register_done.html', {'new_member':new_member})
else:
member_form = RegisterForm()
return render(request, 'accounts/register.html', {'form':member_form})
forms.py
class RegisterForm(UserCreationForm):
email = forms.EmailField(
label=('이메일'),
required=True,
widget=forms.EmailInput(
attrs={
'class': 'form-control',
'required': 'True',
}
)
)
class Meta:
model = Member
fields = ['name', 'username', 'phone', 'email']
def clean_password2(self):
cd = self.cleaned_data
if cd['password1']!=cd['password2']:
raise forms.ValidationError
return cd['password2']
Различные html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hello</title>
</head>
<body>
</body>
</html>