Commit 013cca61 authored by Jose Luis Bautista's avatar Jose Luis Bautista

Home page name feature implemented

parent 0ea1e560
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<h1> Hello! What is your name? </h1> <h1> Hello! What is your name? </h1>
<form method = "POST"> <form url = "home" method = "POST">
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}
<input type="submit" name="submit" id = "submit" value = "Submit Name"> <input type="submit" name="submit" id = "submit" value = "Submit Name">
......
...@@ -4,14 +4,24 @@ from django.views import View ...@@ -4,14 +4,24 @@ from django.views import View
from datetime import datetime from datetime import datetime
from .forms import home, profile, key, this_week, today from .forms import home, profile, key, this_week, today
name = None
form = None
def page_home(request): def page_home(request):
if request.method == 'POST': global name
form = home(request.POST) global form
if form.is_valid():
return render(request, 'home.html', {'form' : form, 'name' : form.cleaned_data['name']}) if name == None:
if request.method == 'POST':
form = home(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
return render(request, 'home.html', {'form' : form, 'name' : name})
else:
form = home()
return render(request, 'home.html', {'form' : form})
else: else:
form = home() return render(request, 'home.html', {'form' : form, 'name' : name})
return render(request, 'home.html', {'form' : form})
def page_profile(request): def page_profile(request):
return render(request, 'profile.html') return render(request, 'profile.html')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment