def users(request):
    #    users = User.objects.order_by('email')
    #    user_dict = {'user_records' : users}
    #    return render(request, 'AppTwo/users.html', context=user_dict)
    form = NewUserForm()

    if request.method == 'POST':
        form = NewUserForm(request.POST)

        if form.is_valid():
            form.save(commit=True)
            return index(request)
        else:
            print('ERROR FORM INVALID')

    return render(request, 'AppTwo/users.html', {'form': form})
def user_page(request):

    form = NewUserForm()

    if request.method == "POST":
        form = NewUserForm(request.POST)

        if form.is_valid:
            form.save(commit=True)  #This line saves the form
            return index(request)  #This brings you back to the homepage
        else:
            print("ERROR FORM INVALID")

    return render(request, 'AppTwo/registration.html', {'form': form})
Exemple #3
0
def users(request):
    # user_list = User.objects.order_by('first_name')
    # user_dict = {'users':user_list}
    # return render(request, 'AppTwo/users.html', context=user_dict)

    form = NewUserForm()

    if (request.method == "POST"):
        form = NewUserForm(request.POST)

        if (form.is_valid()):
            form.save(commit=True)

            return index(request)

        else:
            print("Error Form Invalid!")

    return render(request, 'AppTwo/users.html', {'form': form})