def tag_model(cls, admin_cls=None, field_name=u'tags', sort_tags=False, select_field=False, auto_add_admin_field=True, admin_list_display=True):
 try:
  from tagging.registry import register as tagging_register
 except ImportError:
  from tagging import register as tagging_register
 cls.add_to_class(field_name, (TagSelectField if select_field else TagField)(field_name.capitalize(), blank=True))
 try:
  tagging_register(cls, tag_descriptor_attr=(u'tagging_' + field_name))
 except AlreadyRegistered:
  return
 if admin_cls:
  if admin_list_display:
   admin_cls.list_display.append(field_name)
  admin_cls.list_filter.append(field_name)
  if (auto_add_admin_field and hasattr(admin_cls, u'add_extension_options')):
   admin_cls.add_extension_options(_(u'Tagging'), {u'fields': (field_name,)})
 if sort_tags:
  pre_save.connect(pre_save_handler, sender=cls)

def tag_model ( cls , admin_cls = None , field_name = u'tags' , sort_tags = False , select_field = False , auto_add_admin_field = True , admin_list_display = True ) : try : from tagging . registry import register as tagging_register except ImportError : from tagging import register as tagging_register cls . add_to_class ( field_name , ( TagSelectField if select_field else TagField ) ( field_name . capitalize ( ) , blank = True ) ) try : tagging_register ( cls , tag_descriptor_attr = ( u'tagging_' + field_name ) ) except AlreadyRegistered : return if admin_cls : if admin_list_display : admin_cls . list_display . append ( field_name ) admin_cls . list_filter . append ( field_name ) if ( auto_add_admin_field and hasattr ( admin_cls , u'add_extension_options' ) ) : admin_cls . add_extension_options ( _ ( u'Tagging' ) , { u'fields' : ( field_name , ) } ) if sort_tags : pre_save . connect ( pre_save_handler , sender = cls )
tag_model accepts a number of named parameters: admin_cls if set to a subclass of modeladmin .