MCPcopy
hub / github.com/django/django / get_context

Method get_context

django/contrib/postgres/forms/array.py:145–166  ·  view source on GitHub ↗
(self, name, value, attrs=None)

Source from the content-addressed store, hash-verified

143 return id_
144
145 def get_context(self, name, value, attrs=None):
146 attrs = {} if attrs is None else attrs
147 context = super().get_context(name, value, attrs)
148 if self.is_localized:
149 self.widget.is_localized = self.is_localized
150 value = value or []
151 context["widget"]["subwidgets"] = []
152 final_attrs = self.build_attrs(attrs)
153 id_ = final_attrs.get("id")
154 for i in range(max(len(value), self.size)):
155 try:
156 widget_value = value[i]
157 except IndexError:
158 widget_value = None
159 if id_:
160 final_attrs = {**final_attrs, "id": "%s_%s" % (id_, i)}
161 context["widget"]["subwidgets"].append(
162 self.widget.get_context(name + "_%s" % i, widget_value, final_attrs)[
163 "widget"
164 ]
165 )
166 return context
167
168 @property
169 def media(self):

Callers

nothing calls this directly

Calls 3

build_attrsMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected