duck-booking-tool/accounts/views.py

24 lines
733 B
Python
Raw Normal View History

2015-01-12 15:51:54 +00:00
from django.shortcuts import render
from django.views import generic
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.forms import UserCreationForm
class RegistrationFormView(generic.View):
form_class = UserCreationForm
template_name = 'accounts/registration.html'
def get(self, request):
form = self.form_class()
return render(request, self.template_name, { 'form': form })
def post(self, request):
form = self.form_class(request.POST)
if form.is_valid():
form.save()
2014-12-17 12:30:58 +00:00
return HttpResponseRedirect(reverse('booking:list'))
2015-01-12 15:51:54 +00:00
return render(request, self.template_name, {'form': form})