docs: def resolve_widget(self, field):
          """
          Given a Field or BoundField, return widget instance.
  
          Todo:
              Raise an exception if given field object does not have a
              widget.
  
          Arguments:
              field (Field or BoundField): A field instance.
  
          Returns:
              django.forms.widgets.Widget: Retrieved widget from given field.
          """
          # When filter is used within template we have to reach the field
          # instance through the BoundField.
          if hasattr(field, 'field'):
              widget = field.field.widget
          # When used out of template, we have a direct field instance
          else:
              widget = field.widget
  
          return widget