oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
424 stars 81 forks source link

Simplify template inheritance #132

Open telenieko opened 4 years ago

telenieko commented 4 years ago

This PR implements solution 2 of #127, that is: When you extend 'adminlte/base.html' you can override the blocks of the included templates. Thus life is easier.

The demo is updated as an example, where now you do not have to override the sidebar template completely, but only the nav_links block from base.html directly. You could override any other block from there.

Docs are not yet updated as this is still very experimental.

To use, you would only need to properly set the tempalte settings as in the demo:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            str(DEMO_ROOT / 'demo' / 'templates'),
        ],
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
            'loaders': [
                'cruds_adminlte.template_loader.Loader',
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ]
        }
    },
]

No the loaders settings.

This PR needs #128