Re: [Django] #14802: feature request: ability to override default hidden_widget used to render a custom model field when marked as readonly in the admin

2010-12-05 Thread Django
#14802: feature request: ability to override default hidden_widget used to 
render a
custom model field when marked as readonly in the admin
-+--
  Reporter:  nickname123 | Owner:  nobody   
  
Status:  reopened| Milestone:   
  
 Component:  django.contrib.admin|   Version:  1.2  
  
Resolution:  |  Keywords:  sprintdec2010 
hidden_widget
 Stage:  Design decision needed  | Has_patch:  0
  
Needs_docs:  0   |   Needs_tests:  0
  
Needs_better_patch:  0   |  
-+--
Changes (by cogat):

  * milestone:  1.3 =>

Comment:

 Just to clarify, a widget in Django is its representation of an HTML input
 element, so it doesn't make sense to use it for anything that doesn't
 involve displaying and handling an input element. So for read-only fields
 there's no need to use a widget.

 Given this, I think you're asking for each Field to have a method that is
 called by admin that renders the field as a read-only HTML. That's
 something I could get behind (it's better to attach field display to
 fields than to models, and there are currently silly special-cases for
 rendering BooleanFields as icons in the current code) but it needs a
 design decision. Particularly, would the same method, or a variation on
 it, be used to render the field in admin list views? What about mechanisms
 for requiring external javascript/css files needed by the rendering? What
 about specifying read-only fields (so the same method can be used) in non-
 admin forms?

 However, without a patch this won't make it into 1.3, so I'll remove the
 milestone.

-- 
Ticket URL: 
Django 
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-upda...@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.



Re: [Django] #14802: feature request: ability to override default hidden_widget used to render a custom model field when marked as readonly in the admin

2010-12-05 Thread Django
#14802: feature request: ability to override default hidden_widget used to 
render a
custom model field when marked as readonly in the admin
-+--
  Reporter:  nickname123 | Owner:  nobody   
  
Status:  reopened| Milestone:  1.3  
  
 Component:  django.contrib.admin|   Version:  1.2  
  
Resolution:  |  Keywords:  sprintdec2010 
hidden_widget
 Stage:  Design decision needed  | Has_patch:  0
  
Needs_docs:  0   |   Needs_tests:  0
  
Needs_better_patch:  0   |  
-+--
Changes (by nickname123):

  * status:  closed => reopened
  * resolution:  wontfix =>

Comment:

 Replying to [comment:1 cogat]:
 > The admin app doesn't render hidden_widget at all, it just displays
 readonly fields (using `getattr(modelinstance, fieldname)`). AFAICS
 hidden_widget is only used by form previews and form wizards for holding
 on to copies of fields that were entered in an earlier view.
 >
 > If you are asking for a customised way to render a read-only field, then
 it might be helpful to know that you can pass a callable to
 readonly_fields that renders the result you want.
 >
 > {{{
 > class Song(models.Model):
 > band = models.ForeignKey(Band)
 > title = CustomModelField(max_length=100)
 >
 > def rendertitle(self):
 > return "A custom rendering of %s" % self.title
 >
 > class SongAdmin(admin.ModelAdmin):
 > exclude = ('title',)
 > readonly_fields = ('rendertitle', )
 >
 > }}}

 Wouldn't it be a better idea (in the future) to use a widget to render the
 readonly value so that the default appearance can be overridden?  Using a
 field like that may be nice in some situations, but it doesn't work well
 for my use case.

 I don't think it would work well with any abstract model that is used
 repeatedly because you have to remember to add the callable to
 readonly_fields in every model's admin entry that inherits it.  And also
 for admin inlines.

-- 
Ticket URL: 
Django 
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-upda...@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.



Re: [Django] #14802: feature request: ability to override default hidden_widget used to render a custom model field when marked as readonly in the admin

2010-12-04 Thread Django
#14802: feature request: ability to override default hidden_widget used to 
render a
custom model field when marked as readonly in the admin
-+--
  Reporter:  nickname123 | Owner:  nobody   
  
Status:  closed  | Milestone:  1.3  
  
 Component:  django.contrib.admin|   Version:  1.2  
  
Resolution:  wontfix |  Keywords:  sprintdec2010 
hidden_widget
 Stage:  Design decision needed  | Has_patch:  0
  
Needs_docs:  0   |   Needs_tests:  0
  
Needs_better_patch:  0   |  
-+--
Changes (by cogat):

  * status:  new => closed
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * keywords:  hidden_widget => sprintdec2010 hidden_widget
  * needs_docs:  => 0
  * resolution:  => wontfix
  * stage:  Unreviewed => Design decision needed

Comment:

 The admin app doesn't render hidden_widget at all, it just displays
 readonly fields (using `getattr(modelinstance, fieldname)`). AFAICS
 hidden_widget is only used by form previews and form wizards for holding
 on to copies of fields that were entered in an earlier view.

 If you are asking for a customised way to render a read-only field, then
 it might be helpful to know that you can pass a callable to
 readonly_fields that renders the result you want.

 {{{
 class Song(models.Model):
 band = models.ForeignKey(Band)
 title = CustomModelField(max_length=100)

 def rendertitle(self):
 return "A custom rendering of %s" % self.title

 class SongAdmin(admin.ModelAdmin):
 exclude = ('title',)
 readonly_fields = ('rendertitle', )

 }}}

-- 
Ticket URL: 
Django 
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-upda...@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.