4đź‘Ť
I don’t see an obvious solution to this — the models are sorted by their _meta.verbose_name_plural, and this happens inside the AdminSite.index view, with no obvious place to hook custom code, short of subclassing the AdminSite class and providing your own index method, which is however a huge monolithic method, very inheritance-unfriendly.
12đź‘Ť
So I’ve just wrote a django package that will allow you reorder django app list/ rename app label and model names (including 3rd party apps) — you can download it from here:
- Specific way of requiring one of two fields in django model definition
- Django: Best Way to Add Javascript to Custom Widgets
- How to get field names when running plain sql query in django
- Returning form errors for AJAX request in Django
6đź‘Ť
If you don’t mind using a dirty trick, prepend verbose_name_plural
of your models with a certain number of invisible zero-width spaces. E.g. prepend “Email config” with 1 zero-width space, “General config” with 2 and “Network config” with 3. This is really the simplest method and I’ve yet to find any shortcomings.
- Don't know how to convert the Django field skills (<class 'taggit.managers.TaggableManager'>)? graphql
- How to test django caching?
- Image file not deleted when object with ImageField field is deleted
1đź‘Ť
I found this snippet for reordering models in the django admin panel – it works for us (though check out the comments below the snippet for updates to make it work with Django >= 1.4)
And for the longer term there is this django bug report about the ordering of models within apps. The bug report is open at the time of writing this answer.
- Best Practice for Context Processors vs. Template Tags?
- How would I override the perform_destroy method in django rest framework?
0đź‘Ť
If you just want to reorder your apps (tested with Django 1.11.10
).
class MyAdminSite(AdminSite):
def index(self, request, extra_context=None):
if extra_context is None:
extra_context = {}
# Move last app to the top of `app_list`.
app_list = self.get_app_list(request)
app_list.insert(0, app_list.pop(-1))
extra_context['app_list'] = app_list
return super().index(request, extra_context)
- Translating text blocks with Django .. what to do with the HTML?
- Django swagger- How to disable DjangoFilterBackend query filters from delete, put methods?
- Customizing django admin ChangeForm template / adding custom content
- How to force select_related() to select ForeignKeys that have null=True attribute?