title: django custom widget & field as multiple buttons for in wizard form
body: <p>Am trying to build something in a customized matter whereby am trying to use the custom fields and custom widget to achieve my goal. But unfortunately I cannot find enough documentation to guide me through... </p>
  
  <p>In my case, am trying to build the first form of a wizard, the first form will consist of a single field which am passing choices dictionary pre-populated from the database. The dictionary will look something like this </p>
  
  <pre><code>    choices = {
         1 : {
              'display_name'  : 'Bronze',
              'description'  : 'this package contain all the cool features and much more.',
              },
         2 : {
              'display_name'  : 'Silver',
              'description'  : 'this package contain all the cool features and much less.',
              },
      }
  </code></pre>
  
  <p>The dictionary as seen contain the services provided dynamically from the database which will be fed to the field on initializing. On the other hand, I need to build a custom field and widget that would populate the following HTML </p>
  
  <pre><code>    &lt;div class="choices"&gt;
          &lt;div class="span3"&gt;
              &lt;h2&gt;Bronze&lt;/h2&gt;
              &lt;p&gt;
                  this package contain all the cool features and much more.
              &lt;/p&gt;
              &lt;input type="button" name="Bronze" value="1" /&gt;
          &lt;/div&gt;
          &lt;div class="span3"&gt;
              &lt;h2&gt;Silver&lt;/h2&gt;
              &lt;p&gt;
                  this package contain all the cool features and much less.
              &lt;/p&gt;
              &lt;input type="button" name="Silver" value="2" /&gt;
          &lt;/div&gt;            
      &lt;/div&gt;
  </code></pre>
  
  <p>Whereby each span3 represents a row with package description name and button to select and move to the next step in the wizard. On the other hand, I tried to build a simple custom field as following</p>
  
  <pre><code>class PackageField(forms.CharField):
      default_error_messages = {
          'not_valid_package': _(u'Package selected is not a valid package.'),
      }
  
      def to_python(self, value):
          print value
          if value in self.validators:
              return None
          return value
  </code></pre>
  
  <p>and widget.py</p>
  
  <pre><code>class PackageWidget(MultiWidget):
      _choices = ()
      def __init__(self, choices, attrs=None):
          self._choices = choices
          super(PackageWidget, self).__init__(attrs)
  
  
      def render(self, name, value, attrs=None):
  
          output = []
  
          for k, v in self._choices:
              output.append('&lt;div class="span3"&gt;%s&lt;input type="button" class="btn"/&gt;&lt;/div&gt;' % v)
  
          return mark_safe(self.format_output(output))
  </code></pre>
  
  <p>but am sure there is a lot of mistake with the way I wrote the custom field and widget because they are throwing errors. </p>
  
  <p>I would appreciate if someone can guide me in the right direction as for how to write a correct custom field &amp; widget, if someone can pass me a reference where i can read more it would help a lot. </p>