def render(self, form, form_style, context): html = '' instance = form.instance if not instance.pk: return super(InlineDiffField, self).render(form, form_style, context) initial = form.initial opts = instance._meta detail = form.detail for field in self.fields: f = opts.get_field(field) f_html = render_field(field, form, form_style, context, template=self.template, attrs=self.attrs) if f.value_from_object(instance) != initial.get(field, None): current_val = detail.get_field_result(f.name).val html += ('<div class="diff_field" rel="tooltip"><textarea class="org-data" style="display:none;">%s</textarea>%s</div>' % (_('Current: %s') % current_val, f_html)) else: html += f_html return html
def render(self, form, form_style, context): html = '' for field in self.fields: html += ('<div class="diff_field" rel="tooltip"><textarea class="org-data" style="display:none;">%s</textarea>%s</div>' % (_('Current: %s') % self.attrs.pop('orgdata', ''), render_field(field, form, form_style, context, template=self.template, attrs=self.attrs))) return html