Autoforms

2,064 views
2,036 views

Published on

A custome form engine for django

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,064
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
34
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Autoforms

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

×