How to remove spaces from string in django template How to remove spaces from string in django template django django

How to remove spaces from string in django template


From: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#cut

cut

Removes all values of arg from the given string.

For example:

{{ value|cut:" " }}

If value is "String with spaces", the output willbe "Stringwithspaces".

This worked perfectly for what I wanted. Was not easy to find so creating this question to help the google juice for the next person.

So in my example it would be:

<a href="www.somesite.com/lookup?id={{ order.id|cut:" " }}"</a>