On Sun, Jul 11, 2010 at 9:31 PM, André Eriksson <ean...@gmail.com> wrote:
> {% form myform %}
>    {% using birthday=calendar %}
>    {% renderer "as_ul" %}
>    {% autocomplete "name_autocomplete" %}
>    {% doctype xhtml1 %}
> {% endform %}

i like this syntax; it's a lot more readable than a chain of
parameters of filters on a single tag.

> I see this as having several advantages:
>
> 1) It introduces a clearer way of laying out settings.
> 2) It leverages the template engine for specifying defaults in a
> simple but ingenious way:
> {% form myform %}
>    {% include "form_settings.django" %}
> {% endform %}
> -- form_settings.django:
>    {% doctype xhtml1 %}
>    {% replace_widget datetime=calendar %}


personally, i don't think this is a nice solution.  {%include%}'ing a
set of settings is not a default, it's a packaged setting.

i like better to define a python form of the same; IOW document a
mapping, so that your first example would be equivalent to:

myform.render ({
  'birthday_widget':'calendar',
  'renderer': "as_ul",
  'autocomplete': "name_autocomplete",
  'doctype': "xhtml1"
})

or:

myform.render (birthday_widget='calendar', renderer="as_ul",
autocomplete="name_autocomplete", doctype="xhtml1")


and allow the use of either of these syntaxes in settings.py, form
definition or context processors to set defaults.




-- 
Javier

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

Reply via email to