I have a Task model and in my base template I want to display the number of tasks and a list of the tasks.
How can I do this without having to import the Task model manually through my context dictionary in every view?
Right now I have this:
base.html
<span class="notification">{{tasks.count}}</span>
views.py
def dashboard_view(request):
context = {
"tasks": Task.objects.all(),
}
return render(request=request, template_name='main/index.html', context=context)
As one might imagine, having this in every view night not be practical.