views.py 586 B

12345678910111213141516171819202122
  1. from django.shortcuts import render
  2. from . forms import VoterRegistrationForm
  3. # Create your views here.
  4. def index(request):
  5. voter_registration_form = VoterRegistrationForm()
  6. if request.method == 'POST':
  7. voter_registration_form = VoterRegistrationForm(request.POST)
  8. if voter_registration_form.is_valid():
  9. print('Valid')
  10. print(voter_registration_form.cleaned_data)
  11. else:
  12. print('Invalid')
  13. context = {
  14. 'form': voter_registration_form,
  15. }
  16. return render(request, 'vote/index.html', context=context)