django - Crispy Forms: Is there a way to use crispy forms to render a completly readonly form view? -
django - Crispy Forms: Is there a way to use crispy forms to render a completly readonly form view? -
i started utilize django, python , django-crispy-forms weeks ago. have spent lot of time finding way reuse form layout render readonly view.
thinking on dry principle, have not much sense render form crispy , write same layout hand show user input, example, in confirm wizard step, or simple detail view.
is there way this, replacing <input>
elements <span>
or <p>
elements?
thanks in advance.
did mean that? :
class commonformhelper(formhelper): def __init__(self): super(commonformhelper, self).__init__() self.disable_csrf = true self.form_tag = false class commonmodelformwithhelper(forms.modelform): def __init__(self, *args, **kwargs): super(commonmodelformwithhelper, self).__init__(*args, **kwargs) self.base_fields['some_field'].widget = forms.checkboxinput(attrs={'disabled': true}) self.helper = commonformhelper() self.helper.form_show_labels = false self.helper.layout = layout( field('some_field') ) class humansignform(commonmodelformwithhelper): class meta: model = humansign class humandescriptionform(commonmodelformwithhelper): class meta: model = humandescription
django forms django-crispy-forms
Comments
Post a Comment