तो मैं skin the radio buttons पर jQuery UI का उपयोग कर रहा हूं लेकिन मुझे Django को अपना फॉर्म प्रस्तुत करने के तरीके को प्रस्तुत नहीं किया जा सकता है।रेडियो चयन चयन विजेट के साथ Django रूपों को अनुकूलित करना
<table>
<tr>
<td><label for="notify_new_friends">Notify when new friends join</label></td>
<td class="radio">
<input type="radio" name="notify_new_friends" id="notify_new_friends_immediately" value="1" checked="checked"/><label for="notify_new_friends_immediately">Immediately</label>
<input type="radio" name="notify_new_friends" id="notify_new_friends_never" value="0"/><label for="notify_new_friends_never">Never</label>
</td>
</tr>
</table>
तो संक्षेप में प्रस्तुत करने के लिए कि मैं एक वर्ग (रेडियो) के भीतर रेडियो बटन की जरूरत है, जहां वे एक input
और एक label for
है:
मैं इस संरचना की आवश्यकता है।
<ul>
<li><label for="id_notify_new_friends_0"><input type="radio" id="id_notify_new_friends_0" value="0" name="notify_new_friends" /> Immediately</label></li>
<li><label for="id_notify_new_friends_1"><input type="radio" id="id_notify_new_friends_1" value="1" name="notify_new_friends" /> Never</label></li>
</ul>
ठीक है कौन क्या मैं इस सूची-भाग के अलावा हैं:
जब मैं {{ profile_form.notify_new_friends }}
के साथ अपने टेम्पलेट में प्रपत्र प्रस्तुत करना मैं निम्नलिखित मिलता है।
{% for item in profile_form.notify_new_friends %}
{{ item }}
{% endfor %}
जो मुझे देता है:: तो मैं इस पर पाशन जो मुझे लेबल का प्रारूप अलग देता है की कोशिश की
<label><input type="radio" name="notify_new_friends" value="0" /> Immediately</label>
<label><input type="radio" name="notify_new_friends" value="1" /> Never</label>
तो यहां समस्या यह label for
का उपयोग कर बंद हो जाता है और सिर्फ label
यह wrapp के लिए प्रयोग कर शुरू होता है वह यह है कि सब के साथ
मैंने इस तरह कुछ करने का भी प्रयास किया, लेकिन फिर label
और label_tag
कुछ भी प्रस्तुत न करें।
{{ profile_form.notify_new_friends.0 }}
{{ profile_form.notify_new_friends.0.label_tag }}
{{ profile_form.notify_new_friends.0.label }}
तो किसी को पता है कि कैसे मैं इस ठीक से प्रस्तुत कर सकते हैं !?
FYI करें, यह मेरा forms.py है:
self.fields['notify_new_friends'] = forms.ChoiceField(label='Notify when new friends join', widget=forms.RadioSelect, choices=NOTIFICATION_CHOICES)
https://docs.djangoproject.com/en/dev/ref/forms/widgets/#radioselect - क्या आपने इसे पढ़ा? –
@ अलेक्जेंडर ए। सोस्नोव्स्की हाँ, लेकिन लेबल लेबल प्राप्त करने के लिए मैंने 'choice_label' को याद किया था, लेकिन दुर्भाग्य से '{{radio.tag}} कर रहा है, मुझे एक आईडी प्रदान नहीं करता है और इसलिए मैं' लेबल 'नहीं कर सकता जो मुझे करने की ज़रूरत है। – olofom
फ़ील्ड आईडी ऑटो जनरेटेड प्रयास हैं, {{field.auto_id}} –