I would like to participate in Google summer of code. I am proposing
the following contribution and would like to get some feedback about
ways to improve and refine the design and proposal. I have created a
UML diagram of an initial design viewable here
https://docs.google.com/open?id=0B9C40Ej8YB9Ja0IzMVo2Q3JUZkt0dk5vYVAzak43UQ.
A naive implementation can be demoed from the users perspective at
projectnomnom.herokuapp.com.


Django Dynamic List Fields
Roy McElmurry

Problem: Many web applications need to store or gather information in
a list format from users. Furthermore this list is deeply associated
with a model object. The context in which I encountered this problem
is a prime example. A recipe website would like to offer the ability
for users to enter new recipes. In order to do this a dynamic form is
needed that will allow users to give as many ingredients or
instructions as needed. This data is tightly associated with the model
and would therefore be best represented as a single field within the
form.

Overview: Partial homebrew solutions for this problem can be found on
the internet, a good example exists on stack overflow, however these
solutions fall far short. As stated in the stack overflow post, these
solutions are limited to lists of basic types. In the recipe example,
an ingredient is more than just a string or an integer, sophisticated
applications might choose to represent an ingredient as a set of
fields including; item, quantity, prep, etc.

The dynamic list field is a form field that provides the user with the
ability to store arbitrary lists of associated data conveniently in a
form field once a form post is received. This solution simplifies the
task of generating dynamic forms as well as that of organizing and
referencing logically associated data.

Design Goals: The dynamic form field must
render as a list, ordered or unordered
fit into the existing field framework
provide the option for dynamic input generation with javascript
allow for arbitrary independently validated form fields in a list
element
be convertible to a model object with the standard method of providing
the form’s cleaned_data to the model constructor

Stretch goal:
integrate the dynamic form field into the model form framework

Design: The dynamic list field will build on top of another form
object called the base form. The base form defines a set of django
form fields that constitute a list element. Using the django
formset_factory, list elements will be generated for incorporation
with the encompassing form HTML.

Once the form has been filled out and returned to the django
application as a POST request, the data will be parsed as a set of
base form objects and associated with the encompassing model via an
intermediate database table that is automatically queried when the
list field is referenced.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to