Пример #1
0
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
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)