给继承自models.Model
的类添加一句objects = models.Manager()
即可,实例代码如我的models.py
文件:
from django.db import models
# Create your models here.
class Book(models.Model):
objects = models.Manager() # 避免后续IDE找不到objects属性
# id = models.IntegerField() # 自动创建
name = models.CharField(max_length=256)
author = models.CharField(max_length=128)
publisher = models.CharField(max_length=128)
price = models.FloatField()
number = models.IntegerField()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)