Skip to content Skip to sidebar Skip to footer

Simple Inheritance Issue With Django Templates

just getting started in Django, and I have some problems with the inheritances. It just seems that the loop for doesn't work when inheriting other template. Here's my code in base.

Solution 1:

In your app the template folder structure must be something like:

|- preguntasyrespuestas # your app folder
    |- templates
       -base.html
       |- preguntasyrespuestas
          -index.html
          -pregunta_detalle.html
          ....

Templates directory must be in your app folder and inside it must be another folder with the name of your app and inside this must be the template files.

EDIT

If your templates are in the app template folder you should change DIRS to an empty list: DIRS:[]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [], # change here: put an empty list'APP_DIRS': True,
        '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',
            ],
        },
    },
] 

Post a Comment for "Simple Inheritance Issue With Django Templates"