Django isn't PHP.
You're trying to use a template filter inside a template tag. You can use either a tag or a filter, but not both.
For that matter, since the block
tag takes only a label for the block, I'm not sure what the template code you've written is supposed to do. Additionally, are you sure that GET['search']
is valid syntax in a template tag?
I'm guessing a little at your view and template requirements, but here's how I would approach this in your place. There are a number of gaps you'll have to fill in for yourself depending on your circumstances.
In views.py
:
from django.shortcuts import render_to_response
def my_view(request):
request_was_search = False
codes = []
if request.GET.has_key('search'):
request_was_search = True
codes = some_function_you_define_to_get_codes()
return render_to_response('foo.html',
{'codes':codes,
'request_was_search':request_was_search})
In the template:
{% block count %}
{% if request_was_search %}
// do whatever you want here
<p>There were {{ codes|length }} codes submitted.</p>
// end example
{% endif %}
{% endblock %}