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
425 stars 81 forks source link

Using template_name_base with InlineAjaxCRUD view gives a 500 error #89

Open A4TIF opened 6 years ago

A4TIF commented 6 years ago

Try changing template_name_base for an InlineAjaxCRUD and it will give an error.

How does one go about overriding the templates in cruds/ajax folder individually for every InlineAjaxCRUD view?

I can copy ajax folder to my templates/cruds/ajax and work that way, but that will be for every inline view. I'd like to target a specific view with custom template.

Using: Python 2.7 Django 1.11 django-cruds-adminlte 0.13

luisza commented 6 years ago

Code look well.

Maybe you also need to update this template_name_base = "cruds" template_father = "cruds/base.html"

If you give error again, please paste part of the error here.

A4TIF commented 6 years ago

Using template_father in InlinAjaxCRUD shows the whole page base template again within the page, that messed up everything.

Basically, as per docs, if I use template overrides like templates///cruds/ajax/delete.html

Then it wont work.

But using CRUDView I can easily override the templates as above structure. The issue is with InlineAjaxCRUD only, where the overrides dont work.

If I add template_name_base = "cruds/ajax" .. it wont look for my overrides, it will only for template files within site-packages/cruds_adminlte/templates/..

So the issue is with basically the template overrides.

In settings, I use this:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates')
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                ...
                ...
                ...
A4TIF commented 6 years ago

Ok nevermind, looks like it was to do with the order in INSTALLED_APPS

Looks like its still there even if reordering the INSTALLED_APPS

Thanks