Notifications
Clear all

Padding a Field  

   RSS

0

How can I fix the length of a field? I am trying to concatenate several fields together and I need a field padded if the contents are less than the length of the field.

Topic Tags
2 Answers
1

You can use the ljust Django function. Here is an example where a value is set to a fixed length of 10 characters:

{% dictionary_add_key_value object "VALUE" object.VALUE|ljust:10 %}

More documentation on this function can be found here:

https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#ljust

0

This worked well. I had to create a new value in the payload key and use it in my concatenate string. Adding the function directly into the concatenate did not work.

{% dictionary_add_key_value response.payload.ReconvertContract "INCO1" item.INCO1|ljust:3 %}
{% dictionary_add_key_value condition "VAKEY_LONG" condition.VAKEY_LONG|concatenate:response.payload.ReconvertContract.INCO1 %}

Share: