# DB遷移工具
阿新 • • 發佈:2021-01-21
- flask的資料遷移
init
migrate
upgrade
- django的資料遷移
python manage.py makemigrations
python manage.py migrate
- session的使用
def c_title(request): request.session['title'] = request.POST.get('title') request.session['title'] = request.POST.get('name') request.session['title'] = request.POST.get('content') print(request.session.get('title')) return redirect('/three/title’)
- 分頁
title = request.session.get('title') name = request.session.get('name') content = request.session.get('content') student_list = Xiaoshuo.objects.all() if title: student_list = student_list.objects.filter(title__contains=title) if name: student_list = Xiaoshuo.objects.filter(name__contains=name) if content: student_list = student_list.objects.filter(content__contains=content) print(name) //分頁,不完全版,可以不通過session來判斷 student_list = Xiaoshuo.objects.all().filter(name__contains=name).filter(title__contains=title).filter(content__contains=content)