我想比较一个'术语'到词典的值,特别是值的子串。这是必要的,因为值的格式在不同模块之间不同。例如:module1 =' Doe',module2 =' Jane Doe'。在这种情况下要比较的术语是“Doe'”。我该如何解决这个问题?谢谢!
{% if tickets %}
Tickets found:
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Company</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
{% for ticket in tickets %}
<tr>
<td> {{ ticket.id }} </td>
<td> {{ ticket.company.name }} </td>
<td> {{ ticket.summary }} </td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
def search_bar(request):
term = request.GET.get('term')
if term:
results = objCW.search_companies(term) + objCW.search_contacts(term)
tickets = objCW.search_tickets_by_company(term) + objCW.search_tickets_by_contact(term)
context = {'results': results, 'tickets': tickets}
return render(request, 'website/search.html', context)
else:
context = {'': ''}
return render(request, 'website/search.html', context)