本文整理汇总了Python中forms.SearchForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python SearchForm.save方法的具体用法?Python SearchForm.save怎么用?Python SearchForm.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.SearchForm
的用法示例。
在下文中一共展示了SearchForm.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from forms import SearchForm [as 别名]
# 或者: from forms.SearchForm import save [as 别名]
def index(request):
""" index view with the query searchbar """
# TODO : this view needs to be changed
# A HTTP POST?
if request.method == 'POST':
form = SearchForm(request.POST)
# Have we been provided with a valid form?
if form.is_valid():
# Save the search object
search = form.save(commit=True)
# search text
# qtext = form.cleaned_data['query']
# creates the search
try:
symbol = match_ticker_to_searchstring(search.text)
# The user will be shown the plot
return ticker_png(request, symbol)
except Ticker.DoesNotExist:
print """
Search text {}: no matching Ticker found
""".format(search.text)
else:
# The supplied form contained errors
# Just print them to the terminal.
print form.errors
else:
# If the request was not a POST, display the form to enter details.
form = SearchForm()
context = {'form': form}
return render(request, cur_dir + '/index.html', context)