I have written some sample.
it works for me, hope it will be usefull:
from django.contrib.admin.widgets import AdminFileWidget
from django.utils.safestring import mark_safe
class AdminImageFieldWithThumbWidget(AdminFileWidget):
def render(self, name, value, attrs=None):
thumb_html = ''
if value and hasattr(value, "url"):
thumb_html = '<img src="%s" width="60" width="60"/>' %
value.url
return mark_safe("%s%s" % (thumb_html,
super(AdminImageFieldWithThumbWidget, self).render(name, value,
attrs)))
...
class MyModelOptions(admin.ModelAdmin):
...
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'image':
from django import forms
return
forms.CharField(widget=AdminImageFieldWithThumbWidget(**kwargs))
return
super(MyModelOptions,self).formfield_for_dbfield(db_field,**kwargs)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---