aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/profile/views.py
blob: c41e62b95b17ef28ba47f21ae1f09159f8131510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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())