dynamic setup your site base on table django_admin_settings_options
.
support options:
this options in your db, named django_admin_settings_options
, after do migrate.
you can also add your custom option into this table, and use it by templatetags
adminlte_options
with function get_adminlte_option
.
options table has a valid field to control your option work or not.
example:
# adminlte/general_option.html
{% load adminlte_options %}
# here my option_name is site_title, you can custom yourself.
{% get_adminlte_option 'site_title' as adminlte_site_title %}
{% if adminlte_site_title.valid %}
{{ adminlte_site_title.site_title }}
{% else %}
{{ site_title|default:_('Django site admin') }}
{% endif %}
before custom option, you should known what adminlte has used.
Since v1.5.0b0, you don't need modify new template to active select2.
example:
# adminlte/admin.py
@admin.register(Menu)
class MenuAdmin(TreeAdmin):
...
# change_form_template = 'adminlte/menu_change_form.html'
formfield_overrides = {
models.ForeignKey: {'widget': AdminlteSelect}
}
# adminlte/menu_change_form.html
# active the target select
# {% extends 'admin/change_form.html' %}
# {% block extrajs %}
# {{ block.super }}
# <script>
# django.jQuery('#id_content_type').select2();
# </script>
# {% endblock %}
effect:
Since v1.5.0b0, you don't need modify new template to active select2.
example:
# adminlte/admin.py
@admin.register(Menu)
class MenuAdmin(TreeAdmin):
...
# change_form_template = 'adminlte/menu_change_form.html'
formfield_overrides = {
# multiple for ManayToManyField
models.ManayToManyField: {'widget': AdminlteSelectMultiple(
attr={'style': 'width: 100%'}
)}
}
# adminlte/menu_change_form.html
# active the target select
# {% extends 'admin/change_form.html' %}
# {% block extrajs %}
# {{ block.super }}
# <script>
# django.jQuery('#id_content_type').select2();
# </script>
# {% endblock %}
effect:
Custom your menu depends on database && treebeard.
depth 2
only, more will not effective now.
Exchange Menu by click the Exchange Menu
button
left
admin:index
: django url name, recommend./admin/
: django internal url, if you use i18n url, it's not a good choice.http://
: outside urlapp_label:model
in content_type, it will be skipped.The bigger the priority
╰─$ python manage.py shell
Python 3.6.6 (default, Sep 29 2018, 19:18:41)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from django.urls import resolve
In [2]: resolve('/zh-hans/admin/video/parsed/')
Out[2]: ResolverMatch(func=django.contrib.admin.options.changelist_view, args=(), kwargs={},
url_name=video_parsed_changelist, app_names=['admin'], namespaces=['admin'], route=zh-hans/admin/video/parsed/)
django url name = namespaces:url_name
in your setting.py ADMINLTE_SETTINGS
Misleading demo features disabling/enabling
ADMINLTE_SETTINGS = {
'demo': True,
}
Search form disabling/enabling
ADMINLTE_SETTINGS = {
'search_form': True,
}
Skin choice
ADMINLTE_SETTINGS = {
'skin': True,
}
Customer-specific copyright notice
ADMINLTE_SETTINGS = {
'copyright': 'John Smith',
}
Navigation expanded feature, making navigation elements not being hidden under openable menu
ADMINLTE_SETTINGS = {
'navigation_expanded': True,
}
ADMINLTE_SETTINGS = {
'show_apps': ['django_admin_settings', 'auth', 'main'],
}
Main navigation app feature, where app models are put on top of the menu
ADMINLTE_SETTINGS = {
'main_navigation_app': 'django_admin_settings',
}
Modify apps icon & order apps/models
ADMINLTE_SETTINGS = {
'example-app': {
'icon': 'fa-desktop',
'models': {
'example-model': {
'icon': 'fa-archive'
},
'example-model1': {}
}
},
'auth': {
'icon': 'fa-users'
}
}
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарий ( 0 )