Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add field name to the list of fields generated by object_list templatetag #40

Open
joshuadavidthomas opened this issue Feb 7, 2024 · 1 comment

Comments

@joshuadavidthomas
Copy link
Contributor

joshuadavidthomas commented Feb 7, 2024

Currently the fields rendered out in the list view only contain the values. If I want to customize the rendering of a field based on the field name in an overridden neapolitan list template, there's no good way to do this without writing my own object_list templatetag.

For example, I have a status field that I want to render as a pretty badge because I like the way it looks, this isn't really possible since all I would be able to see is the field's value in the template (so "active", "inactive", etc.) and not the field's name.

image

See this relevant commit for how this would look.

With the above commit, I can then just use something like this in my overridden template:

{% for field in object.fields %}
    {% if field.name == "status" %}
        <td class="py-4 px-3 align-top whitespace-nowrap">{% asset_status_badge field.value %}</td>
    {# etc... #}
    {% endif %}
{% endfor %}
@carltongibson
Copy link
Owner

Wondering if just returning a dict isn't the way to go then. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants