#15667: Implement template-based widget rendering
------------------------------------+------------------------
               Reporter:  brutasse  |        Owner:  brutasse
                 Status:  new       |    Milestone:  1.4
              Component:  Forms     |      Version:
             Resolution:            |     Keywords:
           Triage Stage:  Accepted  |    Has patch:  0
    Needs documentation:  0         |  Needs tests:  0
Patch needs improvement:  0         |
------------------------------------+------------------------
Changes (by brutasse):

 * cc: brutasse (added)


Comment:

 Right, so I have a patch but it's too large for Trac :). I'll be using a
 github branch instead:

 https://github.com/brutasse/django/compare/15667-template-widgets

 All the regressiontest changes are whitespace-related, or changes in the
 widget attrs ordering (name="foo" value="bar" vs value="bar" name="foo").

 A few comments on the curent implementation:

 * !ClearableFileInput no longer has its 'template_with_initial' and
 'template_with_clear' arguments. This breaks a widget in the admin but I
 haven't started the admin widget migration yet. The question is whether
 this is supposed to be a public API or not.

 * The !RadioSelect "renderer" API should be deprecated. I left it
 unchanged (although I added !PendingDeprecationWarnings), it still works
 but it's not doing any template-based rendering. The templates give us
 enough flexibility so I'm in favor of starting its deprecation.

 * I added a template loader that is added to the list of loaders, this way
 the templates are always available and they can be overridden in project-
 or app-provided templates. Template caching works as expected, the cached
 loader also caches the forms templates.

 * I chose to explicitly add the input's "name" and "type" to the template
 context instead of leaving it in the "attrs" dictionary. I like it this
 way but I can put it back in the attrs if we decide to.

 TODO:

 * Topic documentation and widget reference (I'll make a draft but I
 '''will''' need help here :)

 * Convert the admin widgets

 * Add tests for the new widgets API (make sure altering template_name,
 get_context_data and get_context work as expected)

 I'll keep reporting my progress here and will update my branch on github.
 As always, comments welcome :)

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15667#comment:7>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to