-2

The duplicated question explains the meaning of 'context', not explaining why it contradict to its original meaning in real life. We will use 'content' instead.

Django documentation define 'context' as:

Context:A dict to be used as the template’s context for rendering.

MB defines it as:

the parts of a discourse that surround a word or passage and can throw light on its meaning

They contradict to each other.

Take an instance to explain my question :

In views.py
context = {key:value}
render(request, template_name, context)


in template
<p> The parts of a discourse that surround a 
word {{ key }} and can throw lights on its meaning.<\p>

Literallly, the 'context' is the parts outside the curly bracket not the parts inside to be filled in.

Now, django's context is the part within bracket.

How to perceive the definition of context in Django?

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
  • The django context is just a bunch of variables that the template has access to. – Shadow Nov 03 '17 at 03:16
  • Duplicate of [The term "Context" in programming?](https://stackoverflow.com/questions/6145091/the-term-context-in-programming). "Context" is not unique to Django, and is commonly using in all programming. – solarissmoke Nov 03 '17 at 03:24
  • Also please stop posting the [same question](https://stackoverflow.com/questions/47087282/the-definition-of-context-contradicts-to-its-original-meaning) multiple times. – solarissmoke Nov 03 '17 at 03:26
  • 'context' is the 'contextual information' submitted for background investigation @solarissmoke – AbstProcDo Nov 03 '17 at 04:39

2 Answers2

1

Think of the context as the environment that the template is parsed in. So when you have something like {{ key }} inside the template, the template engine looks for something in the context that it is executing in to find the value to insert.

The context "surrounds" the template and "gives it meaning".

Josh Karpel
  • 2,110
  • 2
  • 10
  • 21
0

'context' is the 'contextual information' submitted for background investigation

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138