title: Generating custom forms from DB schema
body: <p>I am a current web2py user, but find I still go back to Django once in a while (where I started). Specifically when working on projects where I want to make use of some specific django apps/plugins/extensions that don't yet exist in web2py. </p>
  
  <p>One thing that I can't live without in web2py, which I am looking for a solution for in Django, is the way to create html forms from a db table and being able to then customize their look and layout in the view, without javascript.</p>
  
  <p>Key things I am looking for:</p>
  
  <ol>
  <li>Generate html form from a db table</li>
  <li>Assign custom css classes/ids to each field in the generated html form (js disabled)</li>
  <li>Place each form field/element in a pre-made html view via a method call in the view</li>
  </ol>
  
  <p>i.e. </p>
  
  <p><strong>I have a table A. In web2py I can do (in controller):</strong></p>
  
  <pre><code>def display_form():
     form = SQLFORM(db.table_A)
     #Can I do the following in Django? Assign custom CSS to each form field?
     form.element(_name='email')['_class'] = = "custom_css_classes, list"
  
     if form.accepts(request.vars, session):
         response.flash = 'form accepted'
     elif form.errors:
         response.flash = 'form has errors'
     else:
         response.flash = 'please fill out the form'
     return dict(form=form)
  </code></pre>
  
  <p><strong>Then, in the View I can do:</strong></p>
  
  <pre><code>form.custom.start
  form.custom.widget.name
  form.custom.widget.email
  form.custom.widget.form_field_name
             ...
  &lt;div class="span-5 last"&gt;&lt;input type="submit" class="register_btn" value="Sign Up"&gt;&lt;/input&gt;&lt;/div&gt;
  form.custom.end
  </code></pre>
  
  <p>The above takes a DB table, creates an HTML form, and then lets me stick each separate form field in any place in the pre-made HTML that I want (using those "custom" method calls on the passed "form" object. Including the custom css classes I assigned to each separate field of the generated html form.</p>
  
  <p>See documentation for details on the above code:</p>
  
  <p><a href="http://web2py.com/book/default/chapter/06?search=define_table" rel="nofollow noreferrer">http://web2py.com/book/default/chapter/06?search=define_table</a></p>
  
  <p><a href="http://web2py.com/book/default/chapter/07?search=sqlform#SQLFORM" rel="nofollow noreferrer">http://web2py.com/book/default/chapter/07?search=sqlform#SQLFORM</a></p>
  
  <p><a href="http://web2py.com/book/default/chapter/05?search=#Server-side-DOM-and-Parsing" rel="nofollow noreferrer">http://web2py.com/book/default/chapter/05?search=#Server-side-DOM-and-Parsing</a></p>
  
  <p><a href="http://web2py.com/book/default/chapter/07?search=form.custom" rel="nofollow noreferrer">http://web2py.com/book/default/chapter/07?search=form.custom</a></p>
  
  <p>How do I do the above in Django without dirtying my javascript with layout hacks. Assume javascript is disabled in the browsers where I need my app to run. Furthermore, I would love to make use of Django admin. Pylons solutions also welcome!</p>
  
  <p>Links to articles/tutorials/howtos for this would be greatly appreciated.
  Also, please make an equivalent result of the above code using the method you mention in your response...</p>