Django context variable names for the templates
<p>EDIT:
I know I can change the names of the variables. My question is in the case that I don't want to do that. I want to know what are all the variables that django generates automatically.</p>

<hr>

<p>I'm doing Django's getting started tutorial and I'm on the <a href="https://docs.djangoproject.com/en/1.10/intro/tutorial04/" rel="nofollow">generic views section</a> where at one point it explains:</p>

<blockquote>
  <p>In previous parts of the tutorial, the templates have been provided
  with a context that contains the question and latest_question_list
  context variables. For DetailView the question variable is provided
  automatically â since weâre using a Django model (Question), Django is
  able to determine an appropriate name for the context variable.
  However, for ListView, the automatically generated context variable is
  question_list.</p>
</blockquote>

<p>My problem is that I don't know how Django determines this "appropriate names". I want to know this for when I write my own template. I would want to know what context variable names to use in such template.</p>

<p>From what I can understand, if my model is <code>Question</code>, the <code>question</code> context variable would store that question, and the <code>question_list</code> context variable would store every question.</p>

<p>So my doubt is: What other context variables names can I use? and what would they store? I can't seem to find this on the documentation, please redirect me to it if you know where it is.</p>

<p>You can change the question_list to something else by using the <a href="https://docs.djangoproject.com/en/1.10/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin.context_object_name" rel="nofollow">context_object_name</a> this isn't explained all that well in that part of the documentation, but ...</p>

<blockquote>
  <p>Return the context variable name that will be used to contain the list
  of data that this view is manipulating. If object_list is a queryset
  of Django objects and context_object_name is not set, the context name
  will be the model_name of the model that the queryset is composed
  from, with postfix '_list' appended. For example, the model Article
  would have a context object named article_list.</p>
</blockquote>

<p>is given under <a href="https://docs.djangoproject.com/en/1.10/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin.get_context_object_name" rel="nofollow">get_context_object_name</a> method</p>

<p>This is what that method's <a href="https://github.com/django/django/blob/master/django/views/generic/list.py#L115" rel="nofollow">code</a> looks like, It ought to clear up all doubts:</p>

<pre><code>    """
    Get the name of the item to be used in the context.
    """
    if self.context_object_name:
        return self.context_object_name
    elif hasattr(object_list, 'model'):
        return '%s_list' % object_list.model._meta.model_name
    else:
        return None
</code></pre>

python django django-templates django-class-based-views