Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. CHECKBOX_CHOICES = (('1', 'The first choice'), ('2', 'The Second Choice'))
  2.  
  3. class Order(models.Model):
  4. paid = models.CharField(max_length=350, choices=CHECKBOX_CHOICES)
  5.  
  6. from django import forms
  7. from .models import Order
  8.  
  9. class OrderCreateForm(forms.ModelForm):
  10. class Meta:
  11. model = Order
  12. fields = ['paid']
  13. widgets = {
  14. 'paid': forms.CheckboxSelectMultiple()
  15. }
  16.  
  17. <form action="." method="post" class="order-form">
  18. {{ form.as_ul }}
  19. <p><input type="submit" value="Submit"></p>
  20. {% csrf_token %}
  21. </form>
  22.  
  23. <ul id="id_paid">
  24. <li><label for="id_paid_0"><input type="checkbox" name="paid" value="" checked="" id="id_paid_0">
  25. ---------</label>
  26. </li>
  27. <li><label for="id_paid_1"><input type="checkbox" name="paid" value="1" id="id_paid_1">
  28. The first choice</label>
  29. </li>
  30. <li><label for="id_paid_2"><input type="checkbox" name="paid" value="2" id="id_paid_2">
  31. The Second Choice</label>
  32. </li>
  33. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement