Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Django query for database operation:-




Django provide nosql query means it not support SQL ,We will write query in Object pattern.

class Student(models.Model):
   rno = Model.CharField(max_length=50)
  sname = Model.CharField(max_length=50)

1)  Django query for data insertion:-

   ref =  ModelClass(variable1=value,variable2=value)
   ref.save()


 according to Student Model class

 obj = Student(rno='1001',sname='xyz')
 obj.save()


2)  Django query for data updation:

     for updation ,we will perform two operation first find row  then update row

     s =  Student.objects.get(pk=value)
     s.rno=newvalue
     s.sname=newvalue
     s.save() 

3)  Django query for data deletion:-
    for deletion,we will perform two operation first find row then delete row

    s = Student.objects.get(pk=value)      #  display data in Object
    s.delete()


4)  Django query for data selection:-
   
      s = Student.objects.all()   # display data in QuerySet

5)  Django query for data selection according to columnname

       s = Student.objects.filter(colname=value)   #display Data in QuerySet
   
      

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post