Reputation: 19
i have a Django projet with django-enless-pagination. i would like to paginate some entries, i create inclusion tag witch i run in my view, i pass some data to generate this entries.
In partial i run
{% paginate entries %}
and i have error
Exception Type: KeyError
Exception Value: u'request'
Exception Location: /usr/local/lib/python2.7/dispackages/django/template/context.py in __getitem__, line 57
i dont have any idea what is worng. I need help. Thx for help.
Upvotes: 0
Views: 132
Reputation: 19
i sovled,
evertything was becuse i am a new ;) i don't know that i need pass a context with data to view in inclusion tag, for that a tag should be like that
from django import template
from dls.apps.products.models import Art
from dls.apps.userprofiles.models import Artist
`from django.shortcuts import redirect, get_object_or_404
register = template.Library();
@register.inclusion_tag('shop/templatetags/product_by_art.html',
takes_context=True)
def partart(context,data):
user = get_object_or_404(Artist,user__username=data);
all_prod = Art.objects.filter(user__id=user.id,active=True);
return {'all': all_prod,
'request': context['request']}
context as a function parameter and request
Sorry for trouble, i must teach a liite more :)
Upvotes: 1