S
S
Stanislav Shabalin2020-10-07 01:35:16
Django
Stanislav Shabalin, 2020-10-07 01:35:16

One queryset in different Django templates?

I now use the same queryset in the navigation menu to display in different templates, passed through a context variable.

def index(request):
  context = {
    'exhibitions_list' : Exhibitions.objects.all()
  }
  return render(request, 'index.html', context)


Views are different, and context[''exhibitions_list''] is needed everywhere.

Tell me, is it possible to do without the formation of the same queries for templates with a common part? Can somehow render separately the common part?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-10-07
@Starck43

You need a context processor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question