LhasaDad
LhasaDad

Reputation: 2151

Issue trying to add django-tables2 supprot to project

I am trying to follow the instructions for adding django-tables2 to a project:

http://django-tables2.readthedocs.org/en/latest/pages/tutorial.html

I am following these steps.

  1. pip install django-tables2
  2. Add 'django_tables2' to INSTALLED_APPS
  3. Add 'django.core.context_processors.request' to the context_preprocessors in your template setting OPTIONS.

when I restart and go to the app it complains that context.preprocessors is not an expected key. are the instructions wrong? do they require a particular level of django and the django_tables2 extension?

note my OPTIONS section of settings PY to start looks like 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',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

edited:

i did find the django.core package called out above contains the following contents:

import warnings

from django.template.context_processors import *  # NOQA
from django.utils.deprecation import RemovedInDjango110Warning

warnings.warn(
    "django.core.context_processors is deprecated in favor of "
    "django.template.context_processors.",
    RemovedInDjango110Warning, stacklevel=2)

so looks like the instructions for installing django-tables2 needs to be updated to mention this.

Upvotes: 0

Views: 367

Answers (1)

JL Peyret
JL Peyret

Reputation: 12204

This is what I used to have... Notice the django.core bit.

#had to add this because of django_tables2:
TEMPLATE_CONTEXT_PROCESSORS += ("django.core.context_processors.request",)

Upvotes: 1

Related Questions