django CRUD

Pre-conditions:

          Has been a model (tbl_user), user tables

 

 

1. Inquiry 

  

  # Querying user data table cx username is 

    USER_OBJECT = tbl_user.objects.filter (username = 'cx') 
# tbl_user query all the data table,
    tbl_user.objects.all = RES () 
# fuzzy fuzzy query data query data girder of
tbl_user.objects.filter (username__contains = 'beam') 

 

2. Delete

  

# Delete username is cx data 
    tbl_user.objects.filter (username = 'cx') . Delete ()

  

3. Modify

  

    
Cx is modified # username password 
# Note that if a query is not first () below a.password = '0000' to index or loop A [0] .password = "0000" 
A = tbl_user.objects.filter ( = username "CX"). First () 
a.password = '0000' 
a.save ()

  

4. Insert the data

# Insert data into the table 
    tbl_user.objects.create (username = 'zcx', password = '1234567')

  

 

Guess you like

Origin www.cnblogs.com/Jack-cx/p/11371278.html