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

Method get_context

django/contrib/admin/widgets.py:416–429  ·  view source on GitHub ↗
(self, name, value, attrs)

Source from the content-addressed store, hash-verified

414 self.validator = validator_class()
415
416 def get_context(self, name, value, attrs):
417 try:
418 self.validator(value if value else "")
419 url_valid = True
420 except ValidationError:
421 url_valid = False
422 context = super().get_context(name, value, attrs)
423 context["current_label"] = _("Currently:")
424 context["change_label"] = _("Change:")
425 context["widget"]["href"] = (
426 smart_urlquote(context["widget"]["value"]) if url_valid else ""
427 )
428 context["url_valid"] = url_valid
429 return context
430
431
432class AdminIntegerFieldWidget(forms.NumberInput):

Callers 1

Calls 2

smart_urlquoteFunction · 0.90
get_contextMethod · 0.45

Tested by 1