Пример #1
0
def users(request):
    form = NewUserForm()
    if request.method == 'POST':
        form = NewUserForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return index(request)
    return render(request, 'form.html', {'form': form})
Пример #2
0
def other(request):
    form = NewUserForm()
    if request.method == 'POST':
        form = NewUserForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return home(request)
    return render(request, 'other.html', {'form': form})
Пример #3
0
def signup_users(request):
    form = NewUserForm()
    if request.method == "POST":
        form = NewUserForm(request.POST)

        if form.is_valid():
            form.save(commit=True)  # this will save the form
            return index(request)  # this will returns are to the index page
    return render(request, 'app/signup.html', {'form': form})
Пример #4
0
def user(request):
    form = NewUserForm()
    if (request.method == "POST"):
        form = NewUserForm(request.POST)
        if (form.is_valid()):
            form.save(commit=True)
            return index(request)
        else:
            print("something went wrong")
    return render(request, 'app/abc.html', {'form': form})
Пример #5
0
def users(request):
    form = NewUserForm()
    if request.method == 'POST':
        form = NewUserForm(request.POST)
        if form.is_valid():
            print("Password:" + form.cleaned_data['password'])

            form.save(commit=True)
            return end(request)
    return render(request, 'form.html', {'form': form})
Пример #6
0
def addUser(request):
    if request.method == 'POST':
        Users = User.objects.all()
        form = NewUserForm(request.POST)
        if form.is_valid():
            form.save()

            # render Home Page
            assert isinstance(request, HttpRequest)
            return render(request, 'app/home.html', {
                'title': 'Home Page',
                'year': datetime.now().year,
            })
    else:
        assert isinstance(request, HttpRequest)
        return render(request, 'app/newUser.html', {
            'title': 'New User',
            'year': datetime.now().year,
            'user': User()
        })
Пример #7
0
def signup(request):
    if request.method == "POST":
        form = NewUserForm(request.POST)
        if form.is_valid():
            user = form.save()
            login(request, user)
            messages.success(request, "Registration successful.")
            return redirect("/list_diagram")

        messages.error(request,
                       "Unsuccessful registration. Invalid information.")

    form = NewUserForm()

    return render(request=request,
                  template_name="signup.html",
                  context={"register_form": form})