Skip to content

Vikrant-Arya/django-admin-model-list-order

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

pip install django-admin-model-list-order

Configuration

  1. Add admin_model_list_order to INSTALLED_APPS:
INSTALLED_APPS = (
    ...
    'admin_model_list_order',
    ...
)
  1. Add the AdminModelListOrder to MIDDLEWARE_CLASSES:
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:
ADMIN_MODEL_DEFAULT_PRIORITY = 100
  1. Add the setting admin_order to your admin.py:
class YourModelAdmin(admin.ModelAdmin):
    model = YourModel
    admin_order = 1

Example

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`

About

Custom ordering for the models of apps in the admin app [Django]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages