工作需要的

class FileModelAdmin(djopt.ModelAdmin):
    formfield_overrides = {djmdl.FileField: {'widget': mywdg.FileWidgetWithExample({'file1':mym.People, 'file2':mym.Buy})}}

class FileWidgetWithExample(AdminFileWidget):
    """
    A FileField Widget that shows its current value if it has one.
    """
    def __init__(self, attrs = {}):
        super(FileWidgetWithExample, self).__init__(attrs)

    def render(self, name, value, attrs = None):
        output = []
        output.append(super(FileWidgetWithExample, self).render(name, value, attrs))
        mdl = self.attrs.get(name, '')
        output.append('<p class="help"><a target="_blank" href="/download/?model=%s&filetype=xml">%s</a></p>' % \
                      (mdl._meta.module_name, _('Example')))
        return mark_safe(u''.join(output))

你可能感兴趣的:(java,工作)