From: Tony Mack Date: Sat, 4 May 2013 03:30:41 +0000 (-0400) Subject: PlainTextWidget no longer wipes out the form field value X-Git-Tag: 1.0~61^2~36 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5e71a66942850fed241aac7c23ccc0787f881e32;p=plstackapi.git PlainTextWidget no longer wipes out the form field value --- diff --git a/plstackapi/core/admin.py b/plstackapi/core/admin.py index 86b48a2..1f0744a 100644 --- a/plstackapi/core/admin.py +++ b/plstackapi/core/admin.py @@ -53,9 +53,13 @@ class NodeInline(admin.TabularInline): model = Node extra = 0 -class PlainTextWidget(forms.Widget): - def render(self, _name, value, attrs): - return mark_safe(value) if value is not None else '' +class PlainTextWidget(forms.HiddenInput): + input_type = 'hidden' + + def render(self, name, value, attrs=None): + if value is None: + value = '' + return mark_safe(value + super(PlainTextWidget, self).render(name, value, attrs)) class PlanetStackBaseAdmin(admin.ModelAdmin): save_on_top = False