I am using Django Cookiecutter as template. And by default in urls.py there is following url:
url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name='about'),
and because i need to pass some additional parameters in it i wanted to use it as:
url(r'^about/$', index, name='about'),
Where index is from my views, but when i use the view, my system does not recognise that user is logged in, should i somehow pass user in my index too or what am i doing wrong?
What i am doing in my view:
def index(request):
return render_to_response('pages/about.html', {
'categories': Category.objects.all(),
'posts': Post.objects.all()[:5]
})
I solved it by using render instead of render to response so the method after change looks like this:
def index(request):
categories = Category.objects.all()
posts = Post.objects.all()[:5]
context = {'categories': categories, 'posts': posts}
return render(request, 'pages/home.html', context)