class DefaultValueWidget(forms.widgets.Widget):
    def __init__(self, value, display=None, attrs=None):        
        if isinstance(display, forms.ModelChoiceField):
            try:
                object = display.queryset.get(pk=value)
                self.display = str(object)
            except:
                self.display = None
        # this allows to genericly pass in any field object intending to to
        # catch ModelChoiceFields, without having to care about the actual
        # type.
        elif isinstance(display, forms.Field):
            self.display = None
        else:
            self.display = display
        self.value = value
        super(DefaultValueWidget, self).__init__(attrs)    
        
    def value_from_datadict(self, data, name):
        return self.value
    
    def render(self, name, value, attrs=None):
        if self.display is None: return self.value
        else: return self.display