Ejemplo n.º 1
0
def student_form(request):
    form = forms.StudentForm()

    if request.method == "POST":
        form = forms.StudentForm(request.POST)
    
        if form.is_valid():
            form.save(commit=True)
            return index(request)

    diction = {'title': "student_form", "student_form":form}
    return render(request, 'first_app/student_form.html', context=diction)
Ejemplo n.º 2
0
def student_update(request, student_id):
    student_info = Student.objects.get(pk=student_id)
    form = forms.StudentForm(instance=student_info)
    if request.method == "POST":
        form = forms.StudentForm(request.POST, instance=student_info)

        if form.is_valid():
            form.save(commit=True)
            return index(request)

    diction = {'student_form': form}
    return render(request, 'first_app/student_update.html', context=diction)
Ejemplo n.º 3
0
def Student_Form(request):
    form = forms.StudentForm()
    if request.method == "POST":
        form = forms.StudentForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return redirect("first_app:index")
    context = {
        'Title': "Student Form",
        "student_form": form,
    }
    return render(request, 'student_form.html', context=context)
Ejemplo n.º 4
0
def StudentUpdate(request, student_id):
    student_info = Student.objects.get(pk=student_id)
    form = forms.StudentForm(instance=student_info)
    if request.method == "POST":
        form = forms.StudentForm(request.POST, instance=student_info)

        if form.is_valid():
            form.save(commit=True)
            return redirect("first_app:index")
    context = {
        'Title': "Student Update",
        'student_form': form,
    }
    return render(request, 'student_update.html', context=context)