FORM DATA COLLECT KORAR PORE ONNO PAGE A REDIRECT KORTE -13

 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1ST MATHOD   @@@@@@@@@@@@@@@@@@@@@@@@@@

1.data collect korar pore onnopage e redirect korte
def formdata (request):
    # collecting data
    if request.method=='POST':
        obj=Students(request.POST)
        print(obj)
        # validation check
        if obj.is_valid():
            #getting data
            name1=obj.cleaned_data['name']             # or request.POST['name']
            email1=obj.cleaned_data['email']
            print(name1,email1)
#########?  sob same thakbe sudhu redirect.html name e template banite show kore deta hobe 
            but ai khatre same url dakhabe
            return render(request,'form1/redirect.html',{"nm":name1})

#############################! HTML PART ######################################

<body>

<h1>{{nm}} data has collected<h1>
    
</body>



@@@@@@@@@@@@@@@@@@@@@@@@ 2nd mathod @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@




1.notun template banai your data collected name e 
2.views.py aivabe sajai

from django.shortcuts import render
from .forms import Students
from django.http import HttpResponseRedirect      #!redirect import kore neta hobe

# Create your views here.


def formdata (request):
    # collecting data
    if request.method=='POST':
        obj=Students(request.POST)
        print(obj)
        # validation check
        if obj.is_valid():
            #getting data
            name1=obj.cleaned_data['name']             # !or request.POST['name']
            email1=obj.cleaned_data['email']
            print(name1,email1)
            return HttpResponseRedirect('/home/thankyou/')
    else:
        obj=Students()
        print("get cholce")
    return render(request,'form1/formdata.html',{'dict':obj})


def thankyou(request):
    return render(request,'form1/redirect.html')             #! notun function likchi



                             @@@@@@@      url part in web   @@@@@@@@@@@@@

            
from django.contrib import admin
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('home/',include('enroll.urls')),

]


                                @@@@@@@@@ url part in apps@@@@@@@@@@@@

from django.urls import path
from . import views

urlpatterns = [
    path('regi/',views.formdata,name='formdata'),
    path('thankyou/',views.thankyou,name='thankyou'),


]


Comments

Popular posts from this blog

D WEB LINK