Exemple #1
0
def register(request):

    if request.method == 'POST':
        form = MyUserCreationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/accounts/login/")
    else:
        form = MyUserCreationForm()
    return render_to_response("accounts/register.html", {
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemple #2
0
def signup(request):
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password1']
        form = MyUserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            user = authenticate(username=username, password=password)
            auth_login(request, user)
            messages.success(request, 'Profile successfully created.')
            return redirect(reverse('home'))
    else:
        form = MyUserCreationForm()

    return render(request, 'accounts/signup.html', {'form': form})
Exemple #3
0
def create_new_user(request):
    """
    View to create a new user
    """
    if request.method == 'POST':
        form = MyUserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect("/accounts/login/")
        else:
            return render_to_response("auth/create.html", {
                'form': form,
            })
    else:
        form = MyUserCreationForm()
    return render_to_response("auth/create.html", {
        'form': form,
    }, RequestContext(request))
Exemple #4
0
def register(request):
    if request.method == 'POST':
        form = MyUserCreationForm(request.POST)
        #pdb.set_trace()
        if form.is_valid():
            form.save()
            return render(
                request, 'login.html', {
                    'message':
                    'You are successfully registered. Log in now, please.',
                    'request': request
                })
        else:
            return render(
                request, 'register.html', {
                    'message': 'Please, enter the correct input!',
                    'request': request,
                    'form': form,
                })