Skip to main content

Custom ordering for models in the admin app.

Project description

django-admin-model-list-order

Custom ordering for models in the admin app. You can define your order by admin_order in ModelAdmin

Install

Install django-admin-model-list-order:

.. code-block:: bash

pip install django-admin-model-list-order

Configuration

  1. Add admin_model_list_order to INSTALLED_APPS:

.. code-block:: bash

INSTALLED_APPS = (
    ...
    'admin_model_list_order',
    ...
)
  1. Add the AdminModelListOrder to MIDDLEWARE_CLASSES:

.. code-block:: bash

MIDDLEWARE_CLASSES = (
    ...
    'admin_model_list_order.middleware.AdminModelListOrder',
    ...
)
  1. Add the setting ADMIN_MODEL_DEFAULT_PRIORITY to your settings.py, It will add default priority 100 to modelAdmin:

.. code-block:: bash

ADMIN_MODEL_DEFAULT_PRIORITY = 100
  1. Add the setting admin_order to your admin.py:

.. code-block:: bash

class YourModelAdmin(admin.ModelAdmin):
    model = YourModel
    admin_order = 1

Example

.. code-block:: bash

class Model1(admin.ModelAdmin):
    model = Model 1
    admin_order = 1

.. code-block:: bash

class Model2(admin.ModelAdmin):
    model = Model 2
    admin_order = 2

It will come in app in this order Model 1 Model 2

History

0.0.1 (2021-07-27) ++++++++++++++++++

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-admin-model-list-order-0.0.4.tar.gz (4.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page