Django Creating Views In Hindi – Django In Hindi

Python Django

Django Creating Views In Hindi Django In HindiIs Post Me Django Views Create Karne Wale Hai Or Django Views Kiya Hota Hai Ye Bhi Dekhne Wale Hai Or Is Views Ka Kiya Istemal Hota Hai |

Previous Post Me Hamne Ek Project Create Kiya Tha myproject Name se Or Is Post Me Ham us project ke Liye Ek admin Interface Create Karne Wale Hai |

Django Creating Views In Hindi

Django Views Ka Istemal Display Karne Ke Liye Hota Hai, And Django Views Ko Simple Way Me Kahe To Ye Ek Python Function Hota Hai, Jo Arguments Ke Rup Me web Request Leta Hai, And Return Me web Response Deta Hai, Jo Ki Use Fir Ham Web Pages Show Kar Sakte Hai, Ya Fir Redirect, 404 Error, XML Documents, Images Etc. Kar Sakte Hai |

Django Views Ko Hame Create Karna Padta Hai, Django App Me, Waise Hamne Ek Apps Create Kiya Tha Previous Post Me myapp Ke Name Se, Usme Hi Ham Ek python file views.py Create Karte Hai |

from django.http import HttpResponse

def hello(request):
   text = """<h1>welcome to my app !</h1>"""
   return HttpResponse(text)

Aap views.py File Ko Dekh Sakte Hai, Hamne pahle django.http se HttpResponse Ko import kiya hai, And Uske Bad Hamne Ek Function hello Name Se Creae Kiya Hai Or Wo Arguments Ke Rup Me request Leta Hai, Uske Bad Hamne Ek variable text Create Kiya Hai, Uske Under Hamne html Content Pass Kiya Hai, Uske Bad Fir Hamne return Kar Diya HttpResponse Ko HTML Me |

Uske Bad Fir Hame URL Mapping Karni Hoti Hai, Ise Show Karne Ke Liye, Joki URL Mapping Ham Next Post Me Dekhne Wale Hai |

HttpResponse Ka Istemal Keval render Karne Ke Liye Hota Hai HTML me, Waise rander Karne Ka Ye Best Way Nhi Hai, Isliye render Karne Ke Liye Django Me render Function Ka Istemal Kiya Jata Hai |

render Function Ka Istemal Karne Ke Liye, Sabse Pahle Hamne template Folder Create Karna Padega And Uske Under Ek File hello.html Create Karni Padegi |

Like -: myapp/templates/hello.html

from django.shortcuts import render

def hello(request):
   return render(request, "myapp/template/hello.html")

Aap Dekh Sakte Hai Hamne, Pahle django.shortcuts se render import Kiya Or fir Ek hello Function Create Kiya Hai, And Ab Hamne return render ke Sath request and hello.html Ko Pass Kiya Hai, Joki Ye URL Mapping Karne Ke Bad hello.html , Jo Bhi Content Hoga Wo Hame HTML Page Me Display Ho Jayega |

Next Post Me Ham URL mapping Karne Ke Bad Content Ko Show Karne Wale Hai And Or Bhi New Functionality Ko Dekhne Wale Hai |

Also Read – Dupolx Project In Django

Leave a Reply

Your email address will not be published. Required fields are marked *