1. 程式人生 > 實用技巧 ># DB遷移工具

# DB遷移工具

  1. flask的資料遷移
    1. init
    2. migrate
    3. upgrade
  2. django的資料遷移
    1. python manage.py makemigrations
    2. python manage.py migrate
  3. 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’) 


  1. 分頁
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)