aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/profile/views.py
diff options
context:
space:
mode:
Diffstat (limited to '97suifangqa/apps/profile/views.py')
-rw-r--r--97suifangqa/apps/profile/views.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/97suifangqa/apps/profile/views.py b/97suifangqa/apps/profile/views.py
new file mode 100644
index 0000000..c41e62b
--- /dev/null
+++ b/97suifangqa/apps/profile/views.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+from django.http import HttpResponse, HttpResponseRedirect
+from django.conf import settings
+from django.shortcuts import render
+from django.contrib.auth.views import login, logout
+from django.contrib.auth import login as auth_login
+
+from .forms import UserCreationForm
+
+
+
+def signup(request):
+ u'''
+ 用户注册
+ '''
+ if request.user.is_authenticated():
+ return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
+
+ if request.method == 'POST':
+ form = UserCreationForm(request.POST)
+ if form.is_valid():
+ user = form.save()
+ return HttpResponseRedirect(request.REQUEST.get('next'))
+ else:
+ form = UserCreationForm()
+
+ return render(request, 'registration/signup.html',
+ locals())
+