Django Models In Hindi

Django Models In Hindi

Python Django

Django Models In Hindi -Django In Hindi – Is Post Me Django Models System Ko Cover Karne Wale Hai Or Django Models Kiya Hoti Hai Ye Bhi Dekhne Wale Hai Or Is Models Ka Kiya Istemal Hota Hai |

Learn Previous Post – Django – Template System

Django Models In Hindi

Django Models Ka Istemal Ham Database Ki Tables Ko Create Karne Ke Liye Karte Hai Or Django Models Ki Help Se Hi Data Ko Fateh Karte Hai, Waise Agar Baat Karu ki Models Kiya Hai, To Ye Aap Ye Samnjh Lijiye Ki Models Database Or Views Ke Bich Me Data Ko Handles Karne Ke Smart Tarika Hai, Aap Ise Niche Di Gayi Images Se Dekh Sakte Hai OR Waise Bhi Ham Ise Pure Deep Me Learn Karne Wale Hai |

Aapne SQL Ko Istemal Kiya Hi Hoga, Jab Bhi Ham SQL Ka Istemal Karte Hai To Hamne SQL Ki Query Language Likhni Padti Hai, Lekin Django ORM(Object-Relational Mapper) Support Karta Hai, To Uski Wajah Se Hame SQL ki Commands Ko Likhne Ki Jarurat Nhi Hoti Hai, Django Models Ko Hi Ham ORM Kahte Hai, Iski Help Se Aap Easy Me Tables Create Kar Sakte Hai, Jaise Ki Aap Upper Di Gayi Image Me Dekh Sakte Hai |

Agar Aapko Django Me Database Table Ko Create Karna Hai, To Aapko myproject/myapp/models.py Jana Padega Or Usme Aapko from django.db import models Ye Line Ko Import Karna Hota Hai, Waise Ye Line Aapne Aaphi Likhi hui Aati Hai Models.py File Ke Under |

Agar Hame Database Me Tables Ko Create Karna Hai To Hame Ek Class With_Name Ke Sath Create Karni Hoti Hai, Or Uske Sath Hi Hame Is Class Ko Inherit Karna Hota Hai models.Model ke Sath |

Waise Ise Ham Example Se Jante Hai, Or Dekhte Hai Ki Ham Kaise Django Models Me Tables Ko Create Kar Sakte Hai |

Table Ko Create Karne Ke Liye Aapko myproject/mypp/models.py Me Jana Hoga |

from django.db import models

# Create your models here.
class Contact(models.Model):
    sno = models.AutoField(primary_key = True) 
    name = models.CharField(max_length=255, null= True)
    email = models.EmailField(blank=True)
    
    def __str__(self):
        return self.name

To Aap Upper Diye Gaye Models Ko Dekh Sakte Hai, Isme Hamne Ek Class Create Ki Hai, Jiska Name Rakha Hai Contact Or Usko Hamne models.Model Se Inherit Kiya Hai, Iska Full Explanation Niche Dekh Sakte Hai |

Explanation

  • class Contact(models.Model): – Iska Matlab Hai Ki Hamne Ek Table Create Ki Hai, Jiska Name Hoga Contact |
  • models.AutoField(primary_key = True) -> Iska Matlab Ki Hamne Ek AutoField Create Ki Hai, Jisko Hamne primary_key=True Diya Hai, AutoField Ka Matlab Hota Hai, Automatically Number Generate Hoga, According To Serial Number, Or sno Ek Variable Hai |
  • models.CharField(max_length=255, null= True) -> Iska Matlab Hai Ki Hamne CharField Create Ki Hai, Jisko Hamne Iski Maximum Length 255 Rakhi Hai, Or null = true Rakha Hai |
  • models.EmailField(blank=True) -> Iska Matlab Hai Ki Hamne Email Field Creat Ki Hai, Jisko Hamne blank=true Rakha Hai |
  • Uske Bad def __str__(self): Method Bana Ke Hamne Uske Return (return self.name) Kar Diya Hai, Iska Matlab Hai, Jab Bhi ham Contact Table Me Data Create Karenge To Uske Name (self.name) Ke Sath Save Ho Jayega |

Ab Tak Hamne Models Ko Create Kar Liya Hai |

Jab Bhi Ham Models Ko Create Karte Hai, To Hame Sabse Pahle, myproject/myapp/admin.py Me Register Karna Padta Hai, Kyoki Agar Hame Admin Panel Ke Under Database Contact Ko Dekhna Hai, To Hame Niche Diya Code myproject/myapp/admin.py Me Add Karna Padta Hai With Models Name Ke Sath, Jaise Ki Models Ka Contact.

from django.contrib import admin
from myapp.models import Contact
# Register your moels here.

admin.site.register(Contact)

Jab Ham Models Ko Admin.py Me Add Kar Dete Hai, To Fir Hame python manage.py makemigrations Command Ko Run Karna Padta Hai, Jisse Hamari Table Database Me Add Hone Ke Liye Ready Ho Jati Hai |

Aap Upper Image Dekh Sakte Hai, Jaise hi Hamne makemigrations Commands Ko Run Kiya To Contact Model Create Ho Gaya Hai |

Jab Ham makemigrations cmd ko Run Karte Hai, Tab Hamari Models Ki Table Ready Hoti Jati Hai, Lekin Wo admin Panel Add Nhi Hoti Hai |

Admin Panel Me Add Karne Karne Ke Liye Hame python manage.py migrate Cmd Ko Run Karna Padta Hai, migrate cmd Ka Kaam hai Ki, Jo Table makemigrations se ready hui Hai, Unhe Admin Panel Me Add Kar Dena |

Ye Sab Karne Ke Bad Aap Niche Diye Cmd Line Ko Likhar Enter Press Karna Hai |

$ python manage.py runserver

Isko Run Karne Ke Bad Aap Django Ka Server Istemal Kar Sakte Hai, Django Khud Ka Server Provide Karta Hai |

To Ab Tak Models Contact Final Create Kar Liya Hai, To Ab Dekhne Wale Ki Admin Panel Me Contact Ko Jo Create KIya Hai, Wo Kaisa Dikhta Hai, To Uske LIye Aapko Aapne Admin Panel Me Jana Hoga, Jo ki Aap Niche Image Dekh Sakte Hai

To Aap Dekh Sakte Hai, Hamara Contact Add Ho Gaya Hai, Yaha Par Aap Dhiyan De Ki, Contact Ke Last Me s Automatic Add Ho Gaya Hai, Jisse Uska Name Contacts Ban Gaya Hai |

Ab Ham Contacts Ko Open Karke Ek Contacts Add Karte Hai, Or Fir Dekhte Hai, Ki Hamari Information Save Hoti Hai, Ya Nhi, Agar Information Save Hoti Hai, To Uska Return Me Name Show Hota Hai Ya Nhi |

Hame Data Ko Fill Kar Diya Hai, Ab Save Button Par Click Karte Hai, To Data Save Ho Jayega With Name Ke Sath |

Hamne Finally Models Ko Create Karna Sikh Liya Hai, To Friends Mujhe Umeed Hai, Ki Aapko Kuch Bhi Problem Nhi Hui Hogi, Agar Aapko Ye Post Or Hamara Kaam Accha Lagta Hai, To Please Hamare Kaam Ko Jarur Share Kare Or Hamari Ye Website Ko Bhi Follow Kare |

Leave a Reply

Your email address will not be published.