Django数据库增删查改

以数据表User为例:

class User(models.Model):
    username = models.CharField(max_length=200)
    password = models.CharField(max_length=200)

增:

User.objects.create(username='Isabella', password='123456')

查:

User.objects.filter(username='Isabella')

改:

User.objects.filter(username='Isabella').update(password='1234')

删:

User.objects.filter(username='Isabella').delete()
上一篇:orm的增删改查


下一篇:django之orm多表查询