# 自定义模型类 管理器使用方法
class BookInfoManager(model.Manager):
# 重写all
def all(self):
return self.filter(is_delete=False)
class BookInfo():
................
# 自定义模型类 objects将不再使用
query = BookInfoManage()
# 查询
BookInfo.query.all() # 查询所有 未被逻辑删除的数据
二、Django 表单和模板的使用
views.py
class IndexView(View):
context = {
"city":"beijing"
}
return render(request,"index.html",context)
urls.py
urlpattern = [
url(r"^booktest/$", views.IndexView.as_view())
]
setting.py
urlpattern=[
url(r"^",booktest.urls)
]
templates -----> index.html
<h1>{{city}}</h1>