code: def badge_form(model):
      '''A form factory for a given model badges'''
      class BadgeForm(ModelForm):
          model_class = Badge
  
          kind = fields.RadioField(
              _('Kind'), [validators.DataRequired()],
              choices=model.__badges__.items(),
              description=_('Kind of badge (certified, etc)'))
  
      return BadgeForf badge_form(model):
      '''A form factory for a given model badges'''
      class BadgeForm(ModelForm):
          model_class = Badge
  
          kind = fields.RadioField(
              _('Kind'), [validators.DataRequired()],
              choices=model.__badges__.items(),
              description=_('Kind of badge (certified, etc)'))
  
      return BadgeForm
docs: A form factory for a given model badges