django-unfold icon indicating copy to clipboard operation
django-unfold copied to clipboard

Question: What is 'spec' in filters.html doing? Resolved an issue but not sure if its sustainable

Open eddyojb88 opened this issue 11 months ago • 1 comments

I am not sure what the speccontext in filters.html achieves and whether it is problematic when it has no lookup_val, but the existing code breaks my app.

    {% for choice in choices %}
        {% if choice.selected %}
            <input type="hidden" name="{{ spec.lookup_kwarg }}" value="{{ spec.lookup_val.0 }}" />
        {% endif %}
    {% endfor %}

However, to fix this I overwrote filter.html and included this line instead:

    {% for choice in choices %}
        **{% if spec.lookup_val %}**
            <input type="hidden" name="{{ spec.lookup_kwarg }}" value="{{ spec.lookup_val.0 }}" />
        {% endif %}
    {% endfor %}

My code now 'works' but it feels a bit magic and I'm not sure if this is sustainable. Are you able to advise?

eddyojb88 avatar Feb 28 '24 21:02 eddyojb88

@eddyojb88 would you mind to prepare a repo with minimal example which is causing a problem?

lukasvinclav avatar May 03 '24 17:05 lukasvinclav