Disable ordering in the admin for a model

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from django.contrib import admin
from django.contrib.admin.views.main import ChangeList
from app.models import MyModel


class UnorderedChangeList(ChangeList):

    def get_ordering(self):
        return None, "asc"


class MyModelAdmin(admin.ModelAdmin):

    def get_changelist(self, request, **kwargs):
        """
        Returns the ChangeList class for use on the changelist page.
        """
        return UnorderedChangeList


admin.site.register(MyModel, MyModelAdmin)

More like this

  1. Disable fields in oldforms admin using jQuery by schraal 5 years, 10 months ago
  2. Django Admin Index Custom App & Model Ordering by hsc 2 years, 4 months ago
  3. Orderable inlines using drag and drop with jQuery UI by simon 5 years, 7 months ago
  4. Drag and drop admin list items by chrsgrrtt 3 years, 8 months ago
  5. Ordering Models in Django Site administration screen by btbytes 6 years, 8 months ago

Comments

(Forgotten your password?)