How do I get Django's 'context' variables accessible to more than one view?

460 Views Asked by At

Is it possible to have the variables of a context block accessible to more than one view? Can one create "constants" in Django 'views.py'?

I have two pages: 'index.html' and 'post_list.html'. They both use the model 'Post', but the two pages aren't identical. So the DRY principle went out the window.

A quick search dug out some older questions about writing the variables into 'settings.py' or writing a block of code like def settings...

How is it done with Django 3.x?

0

There are 0 best solutions below