[Answer]-Django – showing just the select box value, no select box

1👍

Sounds like a custom template tag might work. Something like –

from your_module import Product

def get_product_string(value):
    try:
        product = Product.objects.get(pk=value);
        return value + " -- " + product.name
    except DoesNotExist:
        return value

Then alter your template so instead of {{ field.value }} you do can do {{ field.value|get_product_string }}

Leave a comment