<s> from django . forms import util <EOL> from django . forms import fields <EOL> from django import forms <EOL> import json <EOL> class JsonFormField ( fields . CharField ) : <EOL> """<STR_LIT>""" <EOL> widget = forms . Textarea <EOL> default_error_messages = { <EOL> '<STR_LIT>' : u'<STR_LIT>' <EOL> } <EOL> def clean ( self , value ) : <EOL> value = super ( JsonFormField , self ) . clean ( value ) <EOL> try : <EOL> json . loads ( value ) <EOL> except ValueError , e : <EOL> raise util . ValidationError ( e ) <EOL> return value </s>
