#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: <http://code.djangoproject.com/ticket/14802#comment:1>
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-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.

Reply via email to