About the read-only forms part of the proposal: read-only forms will
be easy to implement if the template widget rendering idea will be
included in core.

For example for SelectMultiple widget the base template is probably
something like this:

<select multiple="multiple" name="{{name}}" id="{{id}}">
{% for choice in choices %}
   {% if choice.selected %}
       <option selected="selected" value={{choice.value}}>{{choice}}</
option>
   {% else %}
       <option value={{choice.value}}>{{choice}}</option>
   {% endif %}
{% endfor %}
</select>

If you want a read-only widget, just give it a custom template:

<ul id="{{id}}">
{% for choice in choices %}
    {% if choice.selected %}
        <li>{{choice}}</li>
    {% endif %}
{% endfor %}
</ul>

Now, that was easy :) Combined with template based form rendering, it
would be relatively easy to implement read-only forms. Another reason
why template based form/widget rendering would be nice to have in
core.

By the way, it would be nice to see how the template based rendering
compares to python based rendering in performance terms when rendering
a larger list of choices. But on the other hand, if you have a large
Select/SelectMultiple list there is bound to be some usability issues,
so maybe the performance isn't that important... Sorry for bringing
performance up here again, but I am a speed freak :)

For what it's worth, I implemented somewhat working read-only fields /
widgets some time ago. I have used it a little in some sites, and the
ability to render any model / form easily in display-only mode is a
really nice feature. The work can be found at [1], but it is
incomplete and based on an old version of Django (last commit is from
August 23, 2010).

[1] https://github.com/akaariai/django/tree/ticket10427

 - Anssi


-- 
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