I'm having some trouble passing a string parameter to a href from withing a template.
I have the following url pattern
path('current_observations/<str:mongo_id>',
views.specific_observation,
name='specific_observation')
At current_observations I have several objects which have the mongo ID as an attribute. The idea is to send this id to the new url.
I tried doing the following without success
<a href="{% url 'VM_OrchestratorApp:specific_observation' resource.id|stringformat:s %}">
{{ resource.TITLE }}
</a>
Which returns the error Failed to lookup for key [s]
Tried doing the following also
<a href="{% url 'VM_OrchestratorApp:specific_observation' resource.id|stringformat:'s' %}">
{{ resource.TITLE }}
</a>
But in this case the argument is not being recognized at all.
NOTE: By doing
<a href="{% url 'VM_OrchestratorApp:specific_observation' 'hello' %}">
{{ resource.TITLE }}
</a>
I get redirected to current_observations/hello which is the expected behavior.
Any idea on what could be going wrong with the string formatting?
EDIT:
Based on @Ralf answer, I tried doing the following.
<a href="{% url 'VM_OrchestratorApp:specific_observation' resource.id %}">
{{ resource.TITLE }}
</a>
This returns the following error.
Reverse for 'specific_observation' with arguments '('Some_id',)' not found. 1 pattern(s) tried: ['current_observations/(?P<mongo_id>[^/]+)$']
It seems like a second empty argument is being added when calling the specific_observation url.