Hi Mikhail,

2011/6/22 Mikhail Korobov <kmik...@googlemail.com>:
> Hi Gregor & others,
> I've noticed the https://github.com/idangazit/formrendering and it reminds
> me the approach I'm using for all my django 1.3 projects:
> {# forms/fields/as_dl.html #}
> <dl> <dt> {{ field.label_tag }}} </dt> <dd> {{ field }}
> {% include "forms/fields/errors.html" %} </dd> </dl>
>
> and then:
> <form action='' method='POST'> {% csrf_token %} {% include
> 'forms/fields/as_dl.html' with field=product_form.title %} {% include
> 'forms/fields/as_dl.html' with field=product_form.conditions %}
> <input type='submit'> </form>
>
> This can be used in a loop:
> {# forms/my_as_ul.html #}
> {% include "forms/non_field_errors.html" %}
> <ul>
> {% for field in form %}
> <li>{% include 'form/fields/as_dl.html' %}</li> {% endfor %}
> </ul>
> and then:
> {% include 'forms/my_as_ul.html' with form=product_form %}
> If individual field should be changed then django-widget-tweaks can be used:
> {% load widget_tweaks %}
> <form action='' method='POST'> {% csrf_token %} {% include
> 'fields/as_dl.html' with field=form.title|attr:"autofocus" %}
> {% include 'fields/as_dl.html' with
> field=form.conditions|add_class:"foo"|attr:"type:search" %}
> {% include 'forms/buttons/submit.html' with value="Save" %} </form>
>
> This approach does not provide all the sugar from the Idan's and Gregor's
> proposals (namely, it forces developer to list all fields if one field is to
> be tweaked) but it is quite simple, introduces no new concepts and can be
> used in existing django 1.3 projects.

Idan, me and all the other guys at the sprints were discussing exactly
something like this. We used the syntax from the current proposal because we
thought that matches the already existing includes as close as possible and
let's you utilize template inheritance, while still having the opportunity to
have some extra behaviour.

Look at the final result what Idan wrote down and is currently discussed in
another thread:
http://groups.google.com/group/django-developers/browse_thread/thread/3791152616fd95ae

--
Servus,
Gregor Müllegger

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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