Hey, i need a little help with this django function. I wan’t to insert it into base.html but i cant .. How ?
def my_friends(request):
friendships = request.user.profile.friendships.exclude(pending=True).order_by('-friend__user__last_activity_date')
friendshipsQS = friendships
results = tuplify(friendships.all(), n=3)
return render(request, 'base.html', locals())
You can’t just set up a view that renders
base.htmland hope everything that extends it will use that view as well.You need to use something like a Context Processor to inject values into every context.
http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors
add
python.dot.path.to.my.FriendsContextProcessorto yourTEMPLATE_CONTEXT_PROCESSORSsetting and the dictionary returned above will be available in allRequestContext, which apparentlyrender(...)does for you! Does that mean you’re using trunk?