My code
{% if GET['search'] % }
{% block count codes|length as counter %}
Is the following a valid if -clause as a Django tag?
{% if GET['search'] % }
The following code gives me an error that block takes only one argument.
What is wrong in the code?
{% block count codes|length as counter %}
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
blocktag 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 thatGET['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:In the template: