Reputation: 23
sorry I just learned programming
I have registration template and registration success template.
after user fill the form registration, it will be redirect to registration success template
How to get input value['email'] from registration template and display it in registration success template ?
views.py
class RegisterFormView(TemplateView):
template_name = 'home/register.html'
def get(self, request):
user_form = UserForm()
return self.render_to_response({
'base_url' : settings.BASE_URL,
'user_form': user_form,
})
def post(self, request, *args, **kwargs):
if request.method == 'POST':
user_form = UserForm(request.POST)
if user_form.is_valid():
user = user_form.save()
user.full_name = user_form.cleaned_data.get("full_name")
user.email = user_form.cleaned_data.get("email")
user.phone_number = user_form.cleaned_data.get("phone_number")
user.set_password(user_form.cleaned_data.get("password"))
password = user_form.cleaned_data.get("password")
profile = Profile.objects.create(created_by=user)
user.save()
return redirect(reverse("home:register-success"))
else:
user_form = UserForm(request.POST)
return self.render_to_response({
'base_url' : settings.BASE_URL,
'user_form': user_form,
})
register.html
{{user_form|crispy}}
register-success.html
we have send email activation to {{user.email}}
EDIT
register views.py
class RegisterSuccessView(TemplateView):
template_name = 'home/register-success.html'
def get(self, request):
return self.render_to_response({
'base_url' : settings.BASE_URL,
})
Upvotes: 0
Views: 115
Reputation: 31
Please try replace
return redirect(reverse("home:register-success"))
to
return render(self.request, template_name='home/register-success.html', context={'user': user})
If you want to have another URL for register-success.html you can create an additional view with page and context return
Upvotes: 3