[Fixed]-Parse queryset in templates

1👍

To group on shop, you can use the django group on other properties.
In your case it will be:

{% regroup userfavs by dish.shop as user_favourites %}
{% for item in user_favourites %}
    <span class="one_col">
        {{ item.grouper }} ({{ item.grouper.id }}) {% if not forloop.last %} - {% endif %}
    </span>
{% endfor %}
{% for item in user_favourites %}
    <span class="one_col">
        {% for userfav in item.list %}
            {{ userfav.dish }} ({{ userfav.dish.id }}) {% if not forloop.last %} - {% endif %}
        {% endfor %}
    </span>
{% endfor %}

You will need to set a CSS rule for the class “one_col” to meet your design requirements, which are not part of the question.

Leave a comment