0

I am trying to concatenate the UUID of a record with a base URL to create a scannable QR code that will link to the direct record on the website. When trying to concatenate the two it fails and yields nothing.

The relevant part is device.id which is a UUID for the device. I've string |stringformat:"s" as well and that didn't work. I don't know what the best practice to do this is and am struggling.

<div class="row">
    <div class="col-xs-12 text-center">
        {% with "http://127.0.0.1:8000/ims/device/"|add:device.id as deviceurl %}
        {% qr_from_text deviceurl size=25 %}
        <p class="small text-center">{{deviceurl}}</p>
        {% endwith %}
        <p class="small text-center">{{ device.id }}</p>
    </div>
</div>
Joe Howard
  • 307
  • 5
  • 27
  • check this https://stackoverflow.com/a/4524851/4751726 – shafik Dec 27 '18 at 04:26
  • I've tried this and it doesn't work for me. It seems that the |add filter is only applicable to two strings, the UUID data type isn't cooperating. – Joe Howard Dec 27 '18 at 04:32

1 Answers1

1

Since the |add filter only works with two strings it cannot be used as a general answer. I created a custom |addstr filter and included it in the file which solved the problem.

How to concatenate strings in django templates?

Joe Howard
  • 307
  • 5
  • 27