I installed the module tables 2 and i have the next problem:
Exception Value: Tag {% querystring %} requires django.template.context_processors.request to be in the template configuration in settings.TEMPLATES[]OPTIONS.context_processors) in order for the included template tags to function correctly.
My code is:
Settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR + '/llamadas/plantillas')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
],
},
},
]
Views.py
def home(request):
if request.user.is_authenticated():
llamadas = CallEntry.objects.all()
return render_to_response('inicio.html', {'llamadas': llamadas})
else:
return HttpResponseRedirect('/accounts/login/')
Inicio.html
{% load render_table from django_tables2 %}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />
</head>
<body>
{% render_table llamadas %}
</body>
</html>
Any suggestions?
Thanks !
The
render_to_response
shortcut is not recommended any more.Use the
render
shortcut instead, so that the context processors are used.There is 2 context_processors.request in your settings:
'django.core.context_processors.request',
'django.template.context_processors.request',
maybe only one is necessary...
In onae of my projects I use only: 'django.core.context_processors.request', but the variable in the template, your llamadas, is an objet of type TableReport.