本文整理汇总了Python中main.Main.update_all方法的典型用法代码示例。如果您正苦于以下问题:Python Main.update_all方法的具体用法?Python Main.update_all怎么用?Python Main.update_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main.Main
的用法示例。
在下文中一共展示了Main.update_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import update_all [as 别名]
def index(request):
if request.method == 'POST':
if 'search_all' in request.POST:
sql = Main()
# form = SearchWay(request.POST)
sql.update_all()
return HttpResponseRedirect('/show/new')
elif 'search' in request.POST:
search_form = SearchWay(request.POST)
if search_form.is_valid():
cleaned_data = search_form.cleaned_data
sql = Main.search(dep=cleaned_data['departure'],
arr=cleaned_data['destination'])
request.session['is_search'] = True
if sql:
request.session['search_result'] = sql
else:
request.session['is_false_search'] = True
return HttpResponseRedirect('/show')
else:
sql = Main()
search_way_form = SearchWay(request.POST,
request.POST['departure'],
request.POST['destination'])
if search_way_form.is_valid():
cleaned_data = search_way_form.cleaned_data
rs = sql.get_flight(cleaned_data['departure'],
cleaned_data['destination'])
request.session['is_search'] = True
if rs:
request.session['search_result'] = rs
else:
request.session['is_false_search'] = True
return HttpResponseRedirect('/show')
else:
search_form = SearchWay()
if request.session.get('search_result'):
rs = request.session.get('search_result')
del request.session['search_result']
del request.session['is_search']
return render(request,
'show/index.html',
{
'form': search_form,
'text_header': u'Quá trình kiếm kiếm đã diễn ra thuận lợi',
'rs_path': Path.objects.get(pk=rs),
'text_4_test': u'Kết quả đã tìm được: '
}
)
elif request.session.get('is_search'):
del request.session['is_search']
return render(request,
'show/index.html',
{
'form': search_form,
'text_header': u'Quá trình kiếm kiếm đã diễn ra không thành công',
'rs_path': None,
'text_4_test': u'Không có kết quả cần tìm'
}
)
elif request.session.get('is_false_search'):
del request.session['is_false_search']
return render(request,
'show/index.html',
{
'form': search_form,
'text_header': u'Quá trình kiếm kiếm có sự cố',
'rs_path': None,
'text_4_test': u'Có lỗi đã diễn ra'
}
)
else:
# form = SearchWay()
paths = Path.objects.all()
paginator = Paginator(paths, 50)
page = request.GET.get('page')
try:
path = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
path = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
path = paginator.page(paginator.num_pages)
return render(request,
'show/index.html',
{
'form': search_form,
'list_arcana': path,
'text_header': 'Welcome to the International'
}
)