autoforms
DESCRIPTION
A custome form engine for djangoTRANSCRIPT
![Page 1: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/1.jpg)
AutoFormsA custom form engine for Django
@jeff_kithttp://jeffkit.info
10年12月19日星期日
![Page 2: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/2.jpg)
AutoForms is ...
• A custom form engine for django
• Django Form ++
• Declare form at runtime
• Form serialization
• http://autoforms.sandbox.jeffkit.info
10年12月19日星期日
![Page 3: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/3.jpg)
Who needs AutoForms
• Polling
• information collecting
• custom form in workflow
• a dynamic form in your Django app
• PAAS made in china
10年12月19日星期日
![Page 4: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/4.jpg)
You may seen her before
10年12月19日星期日
![Page 5: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/5.jpg)
How to ...
10年12月19日星期日
![Page 6: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/6.jpg)
installation
• git clone git://github.com/jeffkit/autoforms
• cd autoforms
• python setup.py install
10年12月19日星期日
![Page 7: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/7.jpg)
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日星期日
![Page 8: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/8.jpg)
Form Administration
10年12月19日星期日
![Page 9: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/9.jpg)
Create a Form
10年12月19日星期日
![Page 10: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/10.jpg)
10年12月19日星期日
![Page 11: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/11.jpg)
Supported field types
10年12月19日星期日
![Page 12: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/12.jpg)
Preview the form
10年12月19日星期日
![Page 13: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/13.jpg)
Preview the form
How?
10年12月19日星期日
![Page 14: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/14.jpg)
ADV Field setting
• default value,datasource,validator......
• Custom Field Widget
• Custom Error message
10年12月19日星期日
![Page 15: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/15.jpg)
Advantage setting
10年12月19日星期日
![Page 16: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/16.jpg)
Advantage
Text
10年12月19日星期日
![Page 17: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/17.jpg)
Advantage
Text
Supported Widget types
10年12月19日星期日
![Page 18: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/18.jpg)
Widget Parameters
10年12月19日星期日
![Page 19: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/19.jpg)
Widget Parameters
json string
10年12月19日星期日
![Page 20: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/20.jpg)
Widget Parameters
json string
Ugly!!
10年12月19日星期日
![Page 21: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/21.jpg)
Widget Parameters
json string
Ugly!!
to be change ......
10年12月19日星期日
![Page 22: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/22.jpg)
Custom error message
10年12月19日星期日
![Page 23: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/23.jpg)
Custom error message
10年12月19日星期日
![Page 24: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/24.jpg)
Custom error message
10年12月19日星期日
![Page 25: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/25.jpg)
Custom error message
10年12月19日星期日
![Page 26: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/26.jpg)
Collecting form data
• fill a form @ form/fill/{form-id}/
• overview data @ form/overview/{form-id}/
10年12月19日星期日
![Page 27: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/27.jpg)
Code!Code!Code
• OK,here comes the high level API !
• First of all:
• from autoforms.models import Form
10年12月19日星期日
![Page 28: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/28.jpg)
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日星期日
![Page 29: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/29.jpg)
render a form
• form.as_p()
• form.as_table()
• form.as_ul()
• That’s the regular Django Form api!
10年12月19日星期日
![Page 30: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/30.jpg)
Save form data
• data = request.POST
• form.persist(data)
10年12月19日星期日
![Page 31: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/31.jpg)
Load stored form datas
• datas = form.search(page,size,fields,*args,**kw)
10年12月19日星期日
![Page 32: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/32.jpg)
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日星期日
![Page 33: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/33.jpg)
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日星期日
![Page 34: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/34.jpg)
Sth u can do with autoforms
10年12月19日星期日
![Page 35: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/35.jpg)
Poll/Collecting service
• TODOs:
• A nice form style
• An Embedable (iframe ) form page
• Simple statis logic and charts
10年12月19日星期日
![Page 36: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/36.jpg)
Form storage service
• TODOs:
• A better form data storage backend
• A Pice of javascript code
10年12月19日星期日
![Page 37: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/37.jpg)
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日星期日
![Page 38: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/38.jpg)
TODO
• i18N
• custom widget
• save the files
• a MongoDB form data storage backend
• custom validator
10年12月19日星期日
![Page 39: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/39.jpg)
Questions?
10年12月19日星期日
![Page 40: Autoforms](https://reader033.vdocument.in/reader033/viewer/2022052619/556a6918d8b42ab0468b4ba5/html5/thumbnails/40.jpg)
Thank you!
10年12月19日星期日