tags:

views:

121

answers:

2

I want to have a checkbox for terms and conditions, label of which should contain a link to a page with, well, terms and conditions.

The following field will have the label with the tags escaped.

BooleanField(label="I agree to <a href='terms-conditions.html'>terms&conditions</a>")
+3  A: 

I'm not sure how django works, but if the label in the above code creates a:

<label>I agree to terms&conditions</label>

element then this is NOT the way to do this.

The label element inherently selects the associated field by default, so you'd be mixing 2 click actions (one that checks, and another that opens a window)

I would just add your label, and an a:href beside it.

<label>I agree to terms&conditions</label> (<a href="terms-conditions.html">terms&conditions</a>)
scunliffe
A: 

Let me guess - you're using django_registration - I see I'm not the only person who had this problem:)

As scunliffe said markup is best left out of the label tag - here is a short template snippet to do what you want without resorting to writing the whole thing out in HTML:

{% for field in form %}
    {{ field.label_tag }}
    {% ifequal field.name 'tos' %}
        <a href="/terms/">I have read and agreed to the Terms of Service</a>
    {% endif %}
{% endif %}
jb