unable to override widget

22 views
Skip to first unread message

Nicolas Emiliani

unread,
Jul 15, 2012, 5:12:59 PM7/15/12
to django...@googlegroups.com
Hi!

I'm trying to override the AdminFileWidget with no success. The idea is to get a thumbnail
next to the uploaded files in a tabular view of the admin site. I did the following :

class AdminImageWidget(AdminFileWidget):
    def render(self, name, value, attrs=None):


--
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

Nicolas Emiliani

unread,
Jul 15, 2012, 5:16:42 PM7/15/12
to django...@googlegroups.com
Crap, hit the send key, there it goes. Sorry.


Hi!

I'm trying to override the AdminFileWidget with no success. The idea is to get a thumbnail
next to the uploaded files in a tabular view of the admin site. I did the following :

class AdminImageWidget(AdminFileWidget):
    def render(self, name, value, attrs=None):


Override the widget class for the image field

class ImageGalleryForm(forms.ModelForm):
    '''
        Image Admin form
    '''
    class Meta:
        model = HomeImage
        fields =('image','description','name','height','width',) 
        widgets = {
            'image' : AdminImageWidget,
        }


Here I set the Form

class ImageGaleryInline(admin.TabularInline):
    form = ImageGalleryForm
    model = HomeImage
    extra = 3
           
    fieldsets = [
        (None, {
            'fields' : [
                ('image','description','name','height','width'),
                ]
            }
        ),
    ]


But the widget still shows itself as the AdminFileWidget, Am I missing something ?

Thanks

 

--
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

Nicolas Emiliani

unread,
Jul 17, 2012, 7:28:26 PM7/17/12
to django...@googlegroups.com


On Sunday, July 15, 2012 6:16:42 PM UTC-3, Nicolas Emiliani wrote:
Crap, hit the send key, there it goes. Sorry.


Hi!

I'm trying to override the AdminFileWidget with no success. The idea is to get a thumbnail
next to the uploaded files in a tabular view of the admin site. I did the following :



Just in case somebody reads this : I fxed it, it was working, but an exception inside the 
render method made the output look like the parent widget :S
Reply all
Reply to author
Forward
0 new messages