parameters: (self)
docstring: Adds a bound method, named '_reorder' to the current instance of
          this class, with attributes allow_tags, short_description and
          admin_order_field.
          This can only be done using a function, since it is not possible
          to add dynamic attributes to bound methods.
docstring_summary: Adds a bound method, named '_reorder' to the current instance of
          this class, with attributes allow_tags, short_description and
          admin_order_field.
          This can only be done using a function, since it is not possible
          to add dynamic attributes to bound methods.
docstring_tokens: Adds a bound method named _reorder to the current instance of this class with attributes allow_tags short_description and admin_order_field . This can only be done using a function since it is not possible to add dynamic attributes to bound methods .
function: def _add_reorder_method(self):
          """
          Adds a bound method, named '_reorder' to the current instance of
          this class, with attributes allow_tags, short_description and
          admin_order_field.
          This can only be done using a function, since it is not possible
          to add dynamic attributes to bound methods.
          """
          def func(this, item):
              html = ''
              if this.enable_sorting:
                  html = '<div class="drag js-reorder-{1}" order="{0}">' \
                         '&nbsp;</div>'.format(getattr(item, this.default_order_field), item.pk)
              return mark_safe(html)
  
          setattr(func, 'allow_tags', True)
          # if the field used for ordering has a verbose name use it,
          # otherwise default to "Sort"
          for order_field in self.model._meta.fields:
              if order_field.name == self.default_order_field:
                  short_description = getattr(order_field, 'verbose_name', None)
                  if short_description:
                      setattr(func, 'short_description', short_description)
                      break
          else:
              setattr(func, 'short_description', _('Sort'))
          setattr(func, 'admin_order_field', self.default_order_field)
          setattr(self, '_reorder', MethodType(func, self))
function_tokens: def _add_reorder_method ( self ) : def func ( this , item ) : html = '' if this . enable_sorting : html = '<div class="drag js-reorder-{1}" order="{0}">' '&nbsp;</div>' . format ( getattr ( item , this . default_order_field ) , item . pk ) return mark_safe ( html ) setattr ( func , 'allow_tags' , True ) # if the field used for ordering has a verbose name use it, # otherwise default to "Sort" for order_field in self . model . _meta . fields : if order_field . name == self . default_order_field : short_description = getattr ( order_field , 'verbose_name' , None ) if short_description : setattr ( func , 'short_description' , short_description ) break else : setattr ( func , 'short_description' , _ ( 'Sort' ) ) setattr ( func , 'admin_order_field' , self . default_order_field ) setattr ( self , '_reorder' , MethodType ( func , self ) )