V
V
Vladimir Kuts2016-05-16 10:55:12
Django
Vladimir Kuts, 2016-05-16 10:55:12

How to make all values ​​in Django admin selected by default?

There is a Django admin panel. In it, you need to select the objects to export in the list view.
By default, no objects are selected. I need to click on the checkbox in the header to select all records on the current page, then scroll down and click on the "Select all xxx records" link, which looks like this:

<span class="question" style="display: inline;">
            <a href="javascript:;" title="Нажмите здесь, чтобы выбрать объекты на всех страницах">
                Select all xxx записей</a>
</span>

After that I will be able to export all records.
Attention to the question - what is the best way to make sure that ALL entries are selected by default without rewriting the admin form? Maybe I missed something from the admin panel view options?
The easiest way as far as I can see - you just need to pull some event in the page's javascript scripts when loading.
Until I figure out which one. Tell me if anyone has come across.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2016-05-16
@fox_12 Asker

In general, so far I have implemented such a crutch:
In the appropriate admin template, added added to the initialization of another script:

<script type="text/javascript">
      (function ($) {
        $(document).ready(function ($) {
            $(django.jQuery.fn.actions.defaults.allToggle)[0].click();
            $(django.jQuery.fn.actions.defaults.acrossQuestions + " a")[0].click();
        });
      })(django.jQuery);
    </script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question