1. AutoForms
A custom form engine for Django
@jeff_kit
http://jeffkit.info
2. AutoForms is ...
• A custom form engine for django
• Django Form ++
• Declare form at runtime
• Form serialization
• http://autoforms.sandbox.jeffkit.info
3. Who needs AutoForms
• Polling
• information collecting
• custom form in workflow
• a dynamic form in your Django app
• PAAS made in china
7. config ur Django project
• Append ‘autoforms’ to INSTALL_APPS in
settings.py
• Append “(r'^form/', include('autoforms.urls'))”
to urlpatterns in urls.py
• python manage.py syncdb
• And ....... Rock n’ Roll it !
26. Collecting form data
• fill a form @ form/fill/{form-id}/
• overview data @ form/overview/{form-id}/
27. Code Code Code
• OK here comes the high level API
• First of all:
• from autoforms.models import Form
28. Get a Form
• Empty Form
• form = Form.objects.get(pk=id).as_form()
• Form with data
• data = request.POST
• form = Form.objects.get(pk=id).as_form(data)
• ‘form’ could be a django.forms.Form object!
29. render a form
• form.as_p()
• form.as_table()
• form.as_ul()
• That’s the regular Django Form api!
31. Load stored form datas
• datas = form.search(page,size,fields,*args,**kw)
32. Play with datas
• for data in datas:
• print data.name,data.email,data.message
• ‘data’ is an instance of
autoforms.models.FormInstance
33. A fancy tag
• {% datalist page=1 pagesize=10
fields=name,email template=your-app/your-
template.html %}
• Diaplay your form data in a table.
• All parameters are optional !