Friday, December 19, 2014

Re: change_list html template filter block inject a css class

Hi,

In your custom(?) filter, you could try wrapping your text in <span class="someclass">, and then in mark_safe(), though be careful with that, security-wise.

Honestly, it might be simplest to use Javascript to apply a special class after the fact.

Collin

On Thursday, December 18, 2014 9:54:07 AM UTC-5, Damjan Dimitrioski wrote:
Hi,

the following block of code is an excerpt from change_list.html template:

{% block filters %}
        {% if cl.has_filters %}
          <div id="changelist-filter">
            <h2>{% trans 'Filter' %}</h2>
           


            {% for spec in cl.filter_specs %}
              {% if "somefilter" in spec|slugify %} <!-- The condition works in my project -->
                <div class="tag_type">{% admin_list_filter cl spec %}</div> <!-- This is how I add a new class, is there a simpler way to append a class attribute? -->
             
              {% else %}
                {% admin_list_filter cl spec %}
              {% endif %}

            {% endfor %}
          </div>
        {% endif %}
      {% endblock %}

What I'm looking for is to format some <li >'s based on given conditions.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/672b126c-b5f8-487c-8f0d-9c7478d09a82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment