示例#1
0
文件: views.py 项目: romankulak/knntp
def event(request, event_name_slug):

	# Create a context dictionary which we can pass to the template rendering engine.
	context_dict = {}
	context_dict['result_list'] = None
	context_dict['query'] = None
	if request.method == 'POST':
		query = request.POST.get('query').strip()

		if query:
			#query = query.strip()
			result_list = run_query(query)
			context_dict['result_list'] = result_list
			context_dict['query'] = query

	try:
		event = Event.objects.get(slug=event_name_slug)
		context_dict['event_name'] = event.name

		pages = Page.objects.filter(event=event)

		# Adds our results list to the template context under name pages.
		context_dict['pages'] = pages
		# We also add the event object from the database to the context dictionary.
		context_dict['event'] = event
	except Event.DoesNotExist:
		pass
	

	return render(request, 'app/event.html', context_dict)
示例#2
0
文件: views.py 项目: romankulak/knntp
def search(request):
	cat_list = get_event_list()
	context_dict = {}
	context_dict['cat_list'] = cat_list

	result_list = []

	if request.method == 'POST':
		query = request.POST['query'].strip()

		if query:
			# Run our Bing function to get the results list!
			result_list = run_query(query)

	context_dict['result_list'] = result_list
	return render(request, 'app/search.html', context_dict)