MCPcopy
hub / github.com/django/django / get_context_data

Method get_context_data

django/views/generic/list.py:122–147  ·  view source on GitHub ↗

Get the context for this view.

(self, *, object_list=None, **kwargs)

Source from the content-addressed store, hash-verified

120 return None
121
122 def get_context_data(self, *, object_list=None, **kwargs):
123 """Get the context for this view."""
124 queryset = object_list if object_list is not None else self.object_list
125 page_size = self.get_paginate_by(queryset)
126 context_object_name = self.get_context_object_name(queryset)
127 if page_size:
128 paginator, page, queryset, is_paginated = self.paginate_queryset(
129 queryset, page_size
130 )
131 context = {
132 "paginator": paginator,
133 "page_obj": page,
134 "is_paginated": is_paginated,
135 "object_list": queryset,
136 }
137 else:
138 context = {
139 "paginator": None,
140 "page_obj": None,
141 "is_paginated": False,
142 "object_list": queryset,
143 }
144 if context_object_name is not None:
145 context[context_object_name] = queryset
146 context.update(kwargs)
147 return super().get_context_data(**context)
148
149
150class BaseListView(MultipleObjectMixin, View):

Callers 1

getMethod · 0.45

Calls 4

get_paginate_byMethod · 0.95
paginate_querysetMethod · 0.95
updateMethod · 0.45

Tested by

no test coverage detected