AutoForms A custom form engine for Django @jeff_kit http://jeffkit.info 10年12月19日星期日
May 31, 2015
AutoFormsA custom form engine for Django
@jeff_kithttp://jeffkit.info
10年12月19日星期日
AutoForms is ...
• A custom form engine for django
• Django Form ++
• Declare form at runtime
• Form serialization
• http://autoforms.sandbox.jeffkit.info
10年12月19日星期日
Who needs AutoForms
• Polling
• information collecting
• custom form in workflow
• a dynamic form in your Django app
• PAAS made in china
10年12月19日星期日
You may seen her before
10年12月19日星期日
How to ...
10年12月19日星期日
installation
• git clone git://github.com/jeffkit/autoforms
• cd autoforms
• python setup.py install
10年12月19日星期日
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 !
10年12月19日星期日
Form Administration
10年12月19日星期日
Create a Form
10年12月19日星期日
10年12月19日星期日
Supported field types
10年12月19日星期日
Preview the form
10年12月19日星期日
Preview the form
How?
10年12月19日星期日
ADV Field setting
• default value,datasource,validator......
• Custom Field Widget
• Custom Error message
10年12月19日星期日
Advantage setting
10年12月19日星期日
Advantage
Text
10年12月19日星期日
Advantage
Text
Supported Widget types
10年12月19日星期日
Widget Parameters
10年12月19日星期日
Widget Parameters
json string
10年12月19日星期日
Widget Parameters
json string
Ugly!!
10年12月19日星期日
Widget Parameters
json string
Ugly!!
to be change ......
10年12月19日星期日
Custom error message
10年12月19日星期日
Custom error message
10年12月19日星期日
Custom error message
10年12月19日星期日
Custom error message
10年12月19日星期日
Collecting form data
• fill a form @ form/fill/{form-id}/
• overview data @ form/overview/{form-id}/
10年12月19日星期日
Code!Code!Code
• OK,here comes the high level API !
• First of all:
• from autoforms.models import Form
10年12月19日星期日
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!
10年12月19日星期日
render a form
• form.as_p()
• form.as_table()
• form.as_ul()
• That’s the regular Django Form api!
10年12月19日星期日
Save form data
• data = request.POST
• form.persist(data)
10年12月19日星期日
Load stored form datas
• datas = form.search(page,size,fields,*args,**kw)
10年12月19日星期日
Play with datas
• for data in datas:
• print data.name,data.email,data.message
• ‘data’ is an instance of autoforms.models.FormInstance
10年12月19日星期日
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 !
10年12月19日星期日
Sth u can do with autoforms
10年12月19日星期日
Poll/Collecting service
• TODOs:
• A nice form style
• An Embedable (iframe ) form page
• Simple statis logic and charts
10年12月19日星期日
Form storage service
• TODOs:
• A better form data storage backend
• A Pice of javascript code
10年12月19日星期日
PAAS made in China?!
• a Form is a model
• develop on line with “form + script”
• ok,it’s just a joke :P
10年12月19日星期日
TODO
• i18N
• custom widget
• save the files
• a MongoDB form data storage backend
• custom validator
10年12月19日星期日
Questions?
10年12月19日星期日
Thank you!
10年12月19日星期日