Fix řazení věcí na hlavní stránce adminu
This commit is contained in:
parent
db151006c4
commit
e90cc4e6b3
1 changed files with 23 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
import locale
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.contrib.admin import AdminSite
|
||||||
from django.contrib.flatpages.models import FlatPage
|
from django.contrib.flatpages.models import FlatPage
|
||||||
|
|
||||||
# Note: we are renaming the original Admin and Form as we import them!
|
# Note: we are renaming the original Admin and Form as we import them!
|
||||||
|
@ -24,3 +26,24 @@ class FlatPageAdmin(FlatPageAdminOld):
|
||||||
admin.site.unregister(FlatPage)
|
admin.site.unregister(FlatPage)
|
||||||
admin.site.register(FlatPage, FlatPageAdmin)
|
admin.site.register(FlatPage, FlatPageAdmin)
|
||||||
|
|
||||||
|
locale.setlocale(locale.LC_COLLATE, 'cs_CZ.UTF-8')
|
||||||
|
|
||||||
|
# https://books.agiliq.com/projects/django-admin-cookbook/en/latest/set_ordering.html
|
||||||
|
# FIXME zpraseno pomocí toho, že Python umí bez problému přepisovat funkce
|
||||||
|
def get_app_list(self, request):
|
||||||
|
"""
|
||||||
|
Return a sorted list of all the installed apps that have been
|
||||||
|
registered in this site.
|
||||||
|
"""
|
||||||
|
|
||||||
|
app_dict = self._build_app_dict(request)
|
||||||
|
# Sort the apps alphabetically.
|
||||||
|
app_list = sorted(app_dict.values(), key=lambda x: locale.strxfrm('0') if (x['name'] == "Seminar") else locale.strxfrm(x['name'].lower()))
|
||||||
|
|
||||||
|
# Sort the models alphabetically within each app.
|
||||||
|
for app in app_list:
|
||||||
|
app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower()))
|
||||||
|
|
||||||
|
return app_list
|
||||||
|
|
||||||
|
AdminSite.get_app_list = get_app_list
|
||||||
|
|
Loading…
Reference in a new issue