I want to use href
in the template jinja2
to send the user a specific result based on id
, to learn more about this specific result. I created a route
url: ('view_assessment_result', '/view_assessment_result/{id}')
that displays all the details about a specific result based on id
.
What I want to do:
When a user clicks on a number id
, he will be sent to a route view_assessment_result/{some_id}
that displays the specifics of this page based on the id
one found in the iteration for a in assessment...
. I tried to study cases, but others seem to use Flask , which I DO NOT use. The template code below does not complete the task.
See the code below:
route configuration:
config.add_route('view_assessment_result', '/view_assessment_result/{id}')
jinja template
<tr>
{% for a in assessment_results %}
<td><a href="{{ '/view_assessment_result' }}">{{ a.id }}</a></td>
<td>{{ a.owner }}</td>
<td>{{a.assessment }}</td>
</tr>
{% endfor %}
, , href
:
@view_config(route_name='view_assessment_result', request_method='GET', renderer='templates/analyst_view.jinja2')
def view_assessment_result(request):
with transaction.manager:
assessment_result_id = int(request.matchdict['id'])
assessment_result = api.retrieve_assessment_result(assessment_result_id)
if not assessment_result:
raise HTTPNotFound()