Django Data Form

I am trying to figure out the most elegant way to create a condition form (TNC) using django. User must agree with TNC to proceed. The tricky part is how to insert a scrollable text field into a CNC form that is not editable. Then the user must click on the checkbox or the form is invalid. TNC is an essential document and is located in a text file. Is there a way to load a text file and make this scroll box content.

Any examples of this type of form or something similar?

thank

+5
source share
1 answer

The confusing part is how to insert a scrollable text field into a CNC form that is not editable.

: . .

-... , :

context = {}
with open('/terms-and-conditions.txt') as f:
    context['terms'] = f.read()

:

class MyForm(forms.Form):
    i_agree = forms.BooleanField()

...

<div style="width:600px; height:300px; overflow-y:scroll;">
    {% if form.errors %}
        <h1>You must agree to the TNC</h1>
    {% endif %}
    <form method="post">
        {{ form.as_p }}
        <input type="submit" value="I agree to the TNC" />
    </form>
</div>

- . , readonly textarea, javascript ..

+4

All Articles