R
R
r3b3l2017-08-10 13:49:37
Django
r3b3l, 2017-08-10 13:49:37

Django. How to display in admin panel?

In the Django admin there is a certain display of objects (in two columns): Value1 Value group1 Value2 Value group1 Value3
Value group2 Value4
Value group3 Value5
Value group3 ... I want to convert it to: Value group1 -Value1 -Value2 Value group2 -Value3 Value group3 -Value4 -Value5 In the database, the "values" field has a foreignkey for "value group" To do this, I decided to override admin change_list_result.html in which I wanted to display the table in the desired form.
The following code in change_list_result.html is now responsible for displaying objects in the admin panel:

{% for result in results %}
{% if result.form.non_field_errors %}
    <tr><td colspan="{{ result|length }}">{{ result.form.non_field_errors }}</td></tr>
{% endif %}

<tr class="{% cycle 'row1' 'row2' %}">{% for item in result %}{{ item }}{% endfor %}</tr>
{% endfor %}

How to be further? Or what other ways to solve the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question